eagain.net
eagain.net · Personal blog · on HN since 2007
Antti Kantola's... personal blog by a developer covering Git internals, Go JSON handling, and other programming topics.
What HN saysHN commenters repeatedly recommend 'Git for Computer Scientists' as a clear explanation of Git's simple underlying data structure.
45HN people shared it
29linked it in comments
18stories submitted
481story points
6 months agolast shared
2007people per year2026
Most-shared posts
- 1Git for Computer Scientists (2010)37 people · 451 points · first shared 2007 · 101 comments on HN
- 2Dynamic JSON in Go2 people · 8 points · first shared 2015 · discussion on HN
- 3Keyboards Influenced by Touchscreens (2011)1 people · 16 points · first shared 2024 · 13 comments on HN
- 4Git for Computer Scientists1 people · 2 points · first shared 2013 · discussion on HN
- 5Git for Computer Scientists1 people · 2 points · first shared 2011 · 1 comments on HN
- 6Incremental mapreduce1 people · 1 points · first shared 2009 · discussion on HN
- 7Unmarshaling a heterogeneous JSON array into a Go struct1 people · 1 points · first shared 2020 · discussion on HN
- 8Git storage.2.dot.svg1 people · first shared 2023
- 9Go json kind1 people · first shared 2017
- 10Slides1 people · first shared 2014
What HN people wrote when they linked it
jxf · 2013-11-18
I agree that git can be characterized as having some usability issues; I initially found the documentation obtuse in many places.
My favorite git joke, by far: "git gets easier once you get the basic idea that branches are homeomorphic endofunctors mapping submanifolds of a Hilbert space."
If you're having trouble understanding git but you find yourself comfortable with basic CS terms, you might want to check out Git for Computer Scientists [0]. This really helped put it in perspective for me.
[0] http://eagain.net/articles/git-for-computer-scientists/
arohner · 2013-08-21
One thing I always find interesting about these kinds of problems is that most DBs don't describe how they're implemented. It's easy to use the wrong tool, and then once you learn how e.g. Mongo is implemented, it's obvious, "oh, that's why things are slow".
I'd love to see http://eagain.net/articles/git-for-computer-scientists/, but for every DB technology.
sh1mmer · 2009-01-21
I'd also recommend reading the "Git for computer scientists" linked in this post (http://eagain.net/articles/git-for-computer-scientists/).
john-tells-all · 2026-04-28
Git's data structure is shockingly simple. Here's an article with diagrams on the four basic data types. Also shows why "HEAD" is different from a "commit".
https://eagain.net/articles/git-for-computer-scientists/
js2 · 2024-03-09
Ditto git for computer scientists:
https://eagain.net/articles/git-for-computer-scientists/
tsbx · 2023-11-23
I always get back to this page when trying to understand/show how git works under the hood: https://eagain.net/articles/git-for-computer-scientists/
It summarizes fundamentals clearly.
chx · 2023-11-11
Not sure whether I count as a computer scientist, I only have a math teacher masters and half an information engineering degree, I dropped out.
Even knowing graph theory and understanding git I still don't have the shortest idea what https://eagain.net/articles/git-for-computer-scientists/git-storage.2.… this even wants this to be.
yencabulator · 2023-11-10
You might enjoy https://eagain.net/articles/git-for-computer-scientists
wmanley · 2022-01-18
For me it was "Git for Computer Scientists": https://eagain.net/articles/git-for-computer-scientists/
matheusmoreira · 2021-10-22
I gained a better understanding of git through this document:
https://eagain.net/articles/git-for-computer-scientists/
I'm not a computer scientist and I think it's understandable. Everything became a lot more clear in my mind once I understood the inner workings.
Filligree · 2021-06-21
Take a look at https://eagain.net/articles/git-for-computer-scientists/?
Maybe you've already read it, but this is what let me grok the underlying data.
bacon_waffle · 2021-04-05
This doesn't start with the plumbing commands, but it's along those lines and seemed helpful to some new-to-git folks at work when we started switching to it last year: https://eagain.net/articles/git-for-computer-scientists/
If you're already comfortable with git, the Git Internals section of the book may be better: https://git-scm.com/book/en/v2/Git-Internals-Git-Objects
jstimpfle · 2019-01-16
I found this very helpful: http://eagain.net/articles/git-for-computer-scientists/. Git's data structures are well designed. Once you have internalized them, you will be better equipped to navigate through the jungle of command-line options.
To understand the data structures interactively, use "git cat-file -p HEAD" and continue drilling down to an individual file in a subdirectory with "git cat-file -p OBJECTHASH"
Bromskloss · 2018-03-15
I thought all we needed was the short "Git for Computer Scientists" [0], which consists mostly of images and which had me saying "oh, that wasn't so hard after all".
[0] http://eagain.net/articles/git-for-computer-scientists/
Vendan · 2017-11-23
Better pattern is http://eagain.net/articles/go-json-kind/
Then you do one switch to get the correct message type to decode into, and boom, you can just `.Run` or `.Handle` or however you design the interface, and you are done.
happimess · 2016-11-30
I'm not OP, but I found this to be useful.
http://eagain.net/articles/git-for-computer-scientists/
froh42 · 2016-09-09
With all these recipies - one thing I do whenever I attempt some stunt in git: I assign temporary tags to every changeset that's important.
git tag tmp
git perform-stunt
This eases undoing the stunt without needing to find the "before" state from reflog. And if you use a graphical log viewer (I like SourceTree on Mac) you'll see the tagged state in the history view - which makes things a lot clearer.
And to be aware what happens, there one single explanation of git that helps a lot: http://eagain.net/articles/git-for-computer-scientists/
As soon as you start viewing git as a graph of nodes with branches/tags just being "marked" nodes a lot of things make sense, and whatever "git perform-stunt" you attempt it's easy to explain within that mental model.
peteretep · 2015-05-11
This is surprisingly straight-forward: http://eagain.net/articles/git-for-computer-scientists/
hyc_symas · 2014-05-12
Bolt is still a lot slower than LMDB/GoLMDB. http://eagain.net/talks/go-nuts-and-bolts/slides.html#33
And still very immature.
delinka · 2013-09-26
See also Git for Computer Scientists at http://eagain.net/articles/git-for-computer-scientists/
qznc · 2013-04-10
Git for computer scientists: http://eagain.net/articles/git-for-computer-scientists/
Quick introduction to git internals for people who are not scared by words like Directed Acyclic Graph.
schleyfox · 2011-09-07
I found git to make a lot more sense personally after reading http://eagain.net/articles/git-for-computer-scientists/ . The git parable is also very good.
ollysb · 2011-02-04
I'm also a visual learner, I found reading http://eagain.net/articles/git-for-computer-scientists/ really helped me gain a deep understanding of how git repositories work. It goes into quite a bit of detail but I found that once I'd groked it the various git commands made a lot of sense and that I could really use them in my workflow.
dschobel · 2010-01-20
The one which helped me the most was a moderately technical tutorial entitled GIT for computer scientists.
http://eagain.net/articles/git-for-computer-scientists/
hwork · 2009-11-28
Git for Computer Scientists: http://eagain.net/articles/git-for-computer-scientists/
Peepcode screencast: http://peepcode.com/products/git
GitHub guides: http://github.com/guides/home
baryphonic · 2024-05-01
> Rebase workflows are awful and unintuitive. Leave the rebasing to the git wizards who actually know what they're doing, in no circumstances should this be part of your day-to-day work.
Hard disagree. I hardly consider myself a "rebase wizard," but I've been a near-exclusive practitioner of rebase workflows since I can remember. I find rebasing much more intuitive than workflows with merge commits. Squash merges are fine, but with proper intuition, they appear like a special case of rebase.
In my experience, the resistance to rebasing comes down to fears about "rewriting history" and false intuitions about how git works. I usually allay the former by pointing out that squash merges - which almost everyone approves of - also rewrite history. The latter issue seems to arise from arrows in popular git visualizations pointing in the wrong direction, e.g. in Gitflow.[0] In git, the child commit points to its parent, because each node is immutable. The git data structures are extremely simple (hence why git is so named), consisting of blobs, trees, commits, tags and references. Once you understand how these work in practice, rebase becomes intuitive.[1][2]
IMO, the only thing unintuitive about git is the CLI. Translating the graph operation I want into the commands is sometimes a challenge. Maybe that makes me a (frustrated) wizard after all?
[0] https://nvie.com/img/[email protected]
[1] https://speakerdeck.com/pbhogan/power-your-workflow-with-git?slide=72
[2]…
jonnytran · 2022-08-06
Git isn't designed for "noobs trying to pick up coding just to experiment". It also isn't really designed for solo developers as the OP is about.
Git is designed for collaboration. Git's UI is absolutely unintuitive, especially coming from other version control software. But that's irrelevant. Everyone wants to use it because of the network effect.
In terms of _why_ the UI is unintuitive, I believe it's because it intentionally exposes its internal representation. Unlike its predecessors like subversion, Git has infinite flexibility in terms of the workflow that teams of people can adopt. But the flexibility comes at the cost of learning how to use a distributed graph of commits.
Personally, I never learned git by reading recipes of commands, like the OP. I only really grokked it by understanding how it works internally. This article helped me:
Git for Computer Scientists
https://eagain.net/articles/git-for-computer-scientists/
raju · 2014-03-22
I can attempt to answer your questions briefly
Aren't the arrows all facing the wrong way?
>> No, the arrows are in the right direction. Git maintains a Directed Acyclic Graph (DAG) of commits. Each new commit created points to 0..n parents. So let's say you were on the first commit, and then you created a new commit. The newly created commit is the "child" of the first commit, and has a "parent" pointer that is the SHA of the parent. The parent cannot have pointers to the children since they don't know that one will be created!
Now, if you were to do a merge between branch a and b, assuming it's not a fast-forward merge, a new child commit is created that will have 2 "parent" pointers - the SHA of a and b.
A commit will have 0 parents if it the first commit in a repo.
What happens to a commit after 'git reset' abandons it; can the commit be accessed ever again?
>> That commit is "lost". I put that in quotes because git dosen't immediately throw away the commit (rather there is a garbage collection process that will eventually remove that commit). For the same reason if you happen to know the SHA of the commit you just reset, then you can do a "git checkout <new_branch> <sha>" and create a branch off that commit.
One way to get to that "lost" commit is to use "git reflog" - the reflog (that is ref-log) is a lot that updates each time the "HEAD" moves. Since when you do a "git reset" the HEAD moves from the current commit to another one, the reflog will record…