3 ms·
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". ht
by john-tells-all 5mo ago
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/ https://eagain.net/articles/git-for-computer-scientists/
- packetlost 5mo agoIs HEAD not just a ref to a commit? There's basically only two "things" in git, refs and objects. Git internals are so easy that IMO people should start off by running through this tutorial [0] instead of learning the basics of git porcelain, it makes understanding what's going on so much easier. [0]: https://git-scm.com/book/en/v2/Git-Internals-Git-Objects https://git-scm.com/book/en/v2/Git-Internals-Git-Objects
- skydhash 5mo agoObjects should be split into trees and blobs to make some operations clearer, especially checkout and rename detections.
- packetlost 5mo agoThere's also commits and tags. Commits are important for understanding how branches and histories work. I was just trying to be brief, the types of objects are important and covered in that tutorial.
- WorldMaker 5mo agoHEAD in most operations is usually a ref to a branch, which makes it somewhat unique as a ref type (it's a ref to a ref, double pointer). When it is a ref to a commit, that's a detached HEAD state. Plus HEAD to the CLI can also mean the family of refs under refs/heads/* that relate to the HEADS of each branch (which depending on fetch status may not be the same as the branch ref) and traversal into the reflog.