←back to thread

1062 points mixto | 1 comments | | HN request time: 0.001s | source
Show context
elevatedastalt ◴[] No.42942487[source]
I regularly conduct 2 hr long "Intro to the Git Data Model" courses at my workplace (1-2 times a year). I literally take them into the .git directory and unzip the files to show how everything is just plain text representation of basic data structures. It's honestly cool to see it click in their heads.

We have a basic Git cookbook we share with any new joinees so that they start committing code, but most of them just follow it religiously and don't understand what's going on (unsurprisingly).

However, literally everyone who attends the course comes out with a reasonable working understanding of Git so that they know what's actually happening.

That does NOT mean that they know all the commands well, but those can be trivially Googled. As long as your mental model is right, the commands are not a big deal. And yet, the vast majority of the discussion on HN on every single Git post is about the command line.

Funnily enough the class sounds a lot like the alt text of https://xkcd.com/1597/ (Just think of branches as...), the difference is that that is unironically the right way to teach Git to a technical audience, and they will come out with a fundamental understanding of it that they will never forget.

I honestly think it's such a high ROI time investment that it's silly to not do it.

replies(5): >>42942545 #>>42943759 #>>42943794 #>>42943938 #>>42945620 #
lucasoshiro ◴[] No.42942545[source]
I did it once, I was indeed really nice, and the discussion that we did after was very cool. I put in the last slide of the presentation some questions for my colleagues answer based on the Git data model, e.g.: "Can we move a commit to another branch?" or "What guarantees that we don't have cycles in the commit graph". I was really satisfying that people came out thinking Git, not only using it!
replies(2): >>42942566 #>>42943033 #
o11c ◴[] No.42943033[source]
That last question is a cryptography question in disguise; the answer is "the fact that SHA-1 collisions are still impractical for most people".
replies(1): >>42948812 #
1. lucasoshiro ◴[] No.42948812{3}[source]
Correct!

Even though SHA-1 collision were achieved, they are impractical and we can make the assumption that "if two objects has the same hash, they are the same".

To have a cycle, both commits involved would need to have the hash of the other, which is impossible: the hash of a commit is based on its content, its content contains the hash of its parent.

We could only have a cycle here if we create two commits created after two arbitrary hashes.