Roadmap › Git & GitHub — Version Control from Basics to Advanced › Module: Undo, Inspect and Advanced Git
Lessons in this course (10)
10. How Git stores data — objects, SHA and refs
AdvancedMediumLesson 10 of 10
Git is a content-addressed store. Everything is an object named by its hash:
| Object | Holds |
|---|---|
| blob | File contents |
| tree | A directory: names → blobs/trees |
| commit | Root tree + parent commit(s) + author + message |
| tag (annotated) | Points to a commit with tagger and message |
Branches and tags are refs — small files containing a commit id (.git/refs/heads/main). HEAD usually contains ref: refs/heads/main. "Detached HEAD" means HEAD points directly at a commit, not a branch — commits made there are easy to lose unless you create a branch.
Because each commit includes its parent's id, changing any old commit changes every id after it — that's why rebase and amend create new commits and why rewriting shared history hurts teammates.