Branches Are Just Pointers

Open .git/refs/heads/ directly. A branch is genuinely just a text file holding a commit hash — nothing more.

Every branch you have ever created or heard of — master, spicy-experiments, or any team's feature branch — is genuinely nothing more than a file inside .git/refs/heads/ containing one commit hash. Moving a branch (a commit, a checkout, a reset) is really just git rewriting that one file.\n\nThis lesson proves it directly: read the real files, confirm they match git rev-parse's own output, then create a working branch by literally writing a hash into a new file yourself — no git command required to create it, and git accepts it as a genuine branch anyway.

Reading a Branch's Raw File

cat .git/refs/heads/master
cat .git/refs/heads/spicy-experiments

Each file's entire content is one 40-character SHA-1 hash — the exact commit that branch currently points at. Nothing else is stored there.

Confirming Against git's Own Output

git rev-parse spicy-experiments

The exact same hash the file contains. git rev-parse simply reads that file (or resolves other kinds of references the same way) — it is not consulting some separate, hidden source of truth.

Creating a Branch by Hand

git rev-parse spicy-experiments > .git/refs/heads/manual-branch
git branch

No git branch command was used to create it — a plain shell redirect into a new file inside .git/refs/heads/ was enough. git's own git branch listing shows it anyway, because that is genuinely all a branch is.

refs/heads

The real directory inside .git/ where every local branch is stored, one file per branch, each file's content being exactly the commit hash that branch points at. Confirmed directly in this lab by reading the files themselves.

git rev-parse

Resolves any reference (a branch name, HEAD, a partial hash) to its full, real commit hash. When pointed at a branch, it genuinely reads the same file cat can read directly — confirmed by comparing the two outputs side by side in this lab.

📖 Read the Raw Branch Files

Open both branch files directly and see the real commit hash each one holds.

cd ~/recipes && cat .git/refs/heads/master
cd ~/recipes && cat .git/refs/heads/spicy-experiments

student@lab:~$ cd ~/recipes && cat .git/refs/heads/master 74517298aacd27b2988b7173d81d3e169d3c9420 student@lab:~$ cd ~/recipes && cat .git/refs/heads/spicy-experiments d48142c330c8b7d2258c4460b7056c94ad323709

🔎 Confirm With git rev-parse

Ask git directly for spicy-experiments' hash and compare it to what the file itself contains.

cd ~/recipes && git rev-parse spicy-experiments

student@lab:~$ cd ~/recipes && git rev-parse spicy-experiments d48142c330c8b7d2258c4460b7056c94ad323709

✍️ Create a Branch by Hand

Write spicy-experiments' hash into a brand new file — no git branch command involved — and see git accept it as a real branch anyway.

cd ~/recipes && git rev-parse spicy-experiments > .git/refs/heads/manual-branch
cd ~/recipes && git branch

student@lab:~$ cd ~/recipes && git rev-parse spicy-experiments > .git/refs/heads/manual-branch student@lab:~$ cd ~/recipes && git branch manual-branch * master spicy-experiments

✅ Prove It Actually Works

Check out the hand-made branch and confirm git genuinely treats it exactly like any other real branch.

cd ~/recipes && git checkout manual-branch
cd ~/recipes && git log --oneline -1
cd ~/recipes && git checkout master
cd ~/recipes && git branch -v

student@lab:~$ cd ~/recipes && git checkout manual-branch Switched to branch 'manual-branch' student@lab:~$ cd ~/recipes && git log --oneline -1 d48142c (HEAD -> manual-branch, spicy-experiments) Add ghost pepper chicken wings recipe student@lab:~$ cd ~/recipes && git checkout master Switched to branch 'master' student@lab:~$ cd ~/recipes && git branch -v manual-branch d48142c Add ghost pepper chicken wings recipe * master 7451729 Increase butter back to 175g for a richer flavor spicy-experiments d48142c Add ghost pepper chicken wings recipe ``` git checkout accepted manual-branch with zero complaints, and git log confirms HEAD landed on the exact same real commit spicy-experiments points at — because right now, they genuinely point at the same hash.

Lab 1.3.2 complete. The illusion is gone — a branch is a hash in a file, proven directly:\n\n\n Raw ref files read : ✅ cat .git/refs/heads/*\n Matched git rev-parse : ✅ identical hash, confirmed\n Branch created by hand : ✅ no git branch command used\n Hand-made branch works : ✅ checkout + log, fully real\n

Enable JavaScript to run the live terminal and track your progress.