Fork me on GitHub
#off-topic
<
2022-11-02
>
Augustus15:11:13

As someone who uses git daily, I never fully understood it, and frequently end up in situations where I mess up when trying to do something in git and having to spend a lot of time to fix things. I keep seeing it implied that git is clojurey in that everything is immutable. I sort of get that, that git seperates references and state like clojure does. But I've never been able to use this info to be effective at using git beyond very basic workflows. But the basic workflows (commit a few times on a dev branch then merge to master and repeat) are usually good enough most of the time so I haven't really hunkered down to learn it. What are your favorite resources for truly understanding git, and being able to use its cli in practice, particularly as an experienced programmer that has used it (awkwardly) for years

p-himik15:11:08

I've never really tried it myself, but a friend of mine found this quite helpful: https://learngitbranching.js.org/

3
🙌 1
pavlosmelissinos15:11:08

That game is really good indeed; I wish it had existed when I first started using git. I definitely recommend it. If you're having trouble with git, it might be that your workflow is weird/unorthodox? What are some situations where you think you've messed up? Like what were you trying to do (and how did you eventually do it)?

👍 1
p-himik15:11:29

And there's plenty of other resources: • https://ohmygit.org/https://gitimmersion.com/https://gitready.com/https://githowto.com/ And if you want a really extensive source, there's always the book: https://git-scm.com/book/en/v2 (which I myself will probably never read).

👍 1
Jon Boone16:11:34

I highly recommend https://git-scm.com/book/en/v2 — it can be used as either a tutorial or a reference!!!

👍 1
kenj16:11:44

The git-scm book above is what made me finally "get" git, and got me to a point where I could help undo coworker blunders like force pushing something bad to main 🙂

Martynas Maciulevičius17:11:42

I don't understand how you can push something bad. If you have a feature branch and create a PR which has to pass tests, then how can you push anything bad to master? Because then you'd be force-pushing to the feature branch before the merging. So the master branch would be untouched until you merge. But you don't merge blindly, do you? Pushing something bad can only happen when you're alone on a project. But then it doesn't actually matter.

p-himik17:11:12

If you have a feature branch.

☝️ 1
kenj17:11:47

This was back 13ish years ago, before PRs/code reviews/CI/CD were standard, and our team (still new to git coming from SVN) could still push directly to master whenever

Martynas Maciulevičius17:11:50

So then there is a question: Why are there multiple developers who push into the same branch but don't use feature branches?

Martynas Maciulevičius17:11:57

I remember working at a start-up where the CTO guy was pushing and breaking the code sometimes. And not actually breaking accidentally, but renaming folders, moving files all over the place and so on... You can do this... but then how can you work with it? It's sometimes useful to restructure the project. But well... you have to communicate. So if you blindly push your non-working code this is also lack of communication.

p-himik17:11:11

You're preaching to the choir. :)

Martynas Maciulevičius17:11:38

I'm providing alternative points that can be used to derive the same conclusion, yes 😄

Martynas Maciulevičius17:11:36

> It's sometimes useful to restructure the project. But well... you have to communicate. This point isn't even about git at all. This is about how you work. Recently there was a presentation with John Romero and he said that during the years they wrote Doom they didn't have git and source control at all. They were communicating by owning piece of code and by talking instead.

Stuart17:11:37

> Why are there multiple developers who push into the same branch but don't use feature branches? You've been lucky if you've never worked in an environment where everyone just works directly in the master branch. In my experience this is sadly common, also common to work in master and have 0 tests.

yes 1
Stuart17:11:43

I too find git really confusing, I can fumble through for my day to day basic usage. But anything that deviates from that and I have to get lucky to not make a mess

skylize17:11:13

I recently started https://shop.jcoglan.com/building-git/, which recreates git in Ruby. But I'm writing it in Clojure instead, while also trying to translate into a functional design instead of the OOP style supported by Ruby. Hoping to turn it into a useful library for Clojurists to interact with git repos, with the cli interface being just an example client. 🤞 Probably more than you are asking for, but thought I would bring it up, since a part of my motivation began in the same place. (I'm also very interested in how all the tracking, diffing, merging, etc. actually works.)

skylize18:11:05

Unfortunately I haven't actually made much progress on the book yet, because 🐰🕳️🕳️🕳️ . 😄 The very first "commit" of the book is written with the assumption the project at that step is a single file in a flat project. But even bare Clojure projects already have source and output folders, a cache and other hidden files from tooling. So out on my own, with a plan to read gitignore files, led me to building a parser for POSIX pattern matching, that can then be easily modified for git-specific rules.

hifumi12318:11:43

So far Magit has let me guess my way through Git and do many things I otherwise would've never done with Git, but I'm clueless the moment I'm stuck with the Git CLI

Martynas Maciulevičius18:11:14

Why is your own pattern parser better than POSIX pattern parser?

skylize18:11:32

Not sure what you mean? Does Clojure come with built in parser for POSIX pattern matching?

Martynas Maciulevičius18:11:57

Ah, for a moment I thought that your own implementation of git would be an interface to git -- a wrapper. But what you're doing is a reimplementation which may end up to be non-compatible with git's files as you don't want to use POSIX tools but you decided to reimplement them (the matcher).

Augustus18:11:21

> So far Magit has let me guess my way through Git and do many things I otherwise would've never done with Git, but I'm clueless the moment I'm stuck with the Git CLI I think this is actually a big part of my problem! I too use magit and it let me be lazy about learning git for so long

skylize18:11:22

Yeah, everything written in Clojure. But it needs to stay compatible.

skylize18:11:34

So I have to know what rules are being used for parsing and replicate them.

Martynas Maciulevičius19:11:49

Waiting for the presentation when you'll finish it then 😄 Maybe it will solve branch problems too

skylize19:11:49

Oh, for sure. And instead of an interactive rebase, it will just read your mind. 😉

Martynas Maciulevičius19:11:24

AI, LISP is intended to do AI, yes.

skylize19:11:39

Gheez! I'm teaching myself how to do parsing, just so I can get past page 30 of a 700 page book. And now you want AI for it too?

wizard 1
1
adi06:11:18

@U03099N7XU2 I often find myself teaching git to m'colleagues. For homework, I make them work through: • John Wigley's Git from the Bottom Up: https://jwiegley.github.io/git-from-the-bottom-up/ , and • Ry's Git tutorial: https://johnmathews.is/rys-git-tutorial.html Additional material: • The Version Control section of the lovely "Missing Semester" course: https://missing.csail.mit.edu/2020/version-control/ The key is no copy-pasting anything... type out all the commands / git operations in the terminal. Invariably, people who don't do the typing-out continue to flounder after my workshop. The ones who put in the work develop the sense and confidence that further helps them "see" their version control in their mind's eye, and discover more git for pretty much any situation they may want to solve (bisect, automated bisect, octopus merges, filter-branch rewrites etc).

adi06:11:39

I think git-scm is too vast and improperly structured for the purpose of teaching git. It works very well as a reference book.

paulocuneo21:11:13

I git rebase -i quite a lot when working in a solo branch. Sometimes I mess up the rebase, but I'm able to recover everything with git reflog https://git-scm.com/docs/git-reflog . It's basically a transaction log for git, and it gives you the sha-1 from before the action has taken place, this allows to recover from almost everything

mauricio.szabo04:11:28

Usually the metaphor that works for me with git is that git is like a pearl collar. A branch is a line that makes the collar A commit is a pearl If you start a new branch, you will tie a new line into a specific pearl (the last commit before the branch was created) New commits on this new branch are "pearls" on this new "line" If you merge the branch back on the master/main branch, and there are no commits on that master branch, it's a "fast forward" merge - basically, both "lines" become one If, on the other hand, there are new commits on that master branch, you generate a "merge commit" - basically, a new "pearl" that ties both strings together A "rebase" is the destruction of the line and all pearls, and replace them with new pearls And, that's basically it :)

🙌 1