How Git keeps every version of your project without filling your disk
Git history: how each commit remembers the one before
Change one letter in a Git commit from years ago, and nothing after it matches any more. What holds a Git history together, and why can nobody rewrite it quietly?
-
1
When Git makes a commit, it writes into it which commit came just before, its parent. "Fix the score" knows that its parent is "Sound on".
-
2
Since each commit knows its parent, the commits form a chain. Git walks it back from the newest to the very first, the one with no parent, and that chain is the history of your project.
-
3
A commit does not name its parent by its message, which anyone can write twice. It uses a hash, a long code that Git works out from everything the commit holds: its snapshot, its message, its time, and the hash of its parent.
-
4
So if you change one letter in an old commit, its hash changes. The commit after it held the old hash, so its hash changes too, and so on up to the newest: nobody can change the past quietly.
-
5
Your history runs in one straight line, and Miva plays the newest commit every evening. The night sky could break the whole game: how do you try it without touching her version, and without copying the folder again?
-
Quick check
Two laptops show the same hash on their newest commit.
Show the answer
They are the same all the way back to the first commit. That hash was made from the hash of its parent, which was made from the hash of its own parent, and so on.
-
Go further
The real names behind the history.