How Git stores history
Read objects, refs and HEAD to understand why recovery works.
What you will be able to do
- Inspect commit objects
- Explain what a branch points to
- Use the object graph to diagnose a problem
Git stores content in immutable objects: blobs for files, trees for folders and commits for snapshots. Branches are just pointers to commits, and HEAD points to the branch you are on.
git rev-parse HEAD
git cat-file -t HEAD
git cat-file -p HEAD
git ls-tree HEAD
git show --stat HEAD| Object | Stores |
|---|---|
| blob | File contents |
| tree | A directory: names, modes and object IDs |
| commit | A snapshot, parent, author and message |
| tag | An annotated pointer to an object |
Your turn
MediumInspect the current commit
Show the type and contents of the current HEAD object, then list its tree.
BASH · starter
# your commands hereCheck your understanding before moving on.
Knowledge checkQuestion 1
What does a branch point to?
Select an answer to continue
Study tools
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign inFinished reading?
Lock in what you just learned.
0%
Mark this lesson complete to save your place and move one step closer to the certificate.