What a Branch Really Is
A file with a hash.
Here's the most surprising fact about Git. A branch is just a tiny text file, holding one commit hash. That's why branches are so cheap.

- A branch is a tiny file
- Holding one commit hash
- That's why they're cheap
Branches are files
Inside dot git, refs, heads, there's one file per branch. Cat main shows a single hash, our latest commit. And the file called head simply says, ref, refs slash heads slash main. That's how Git knows which branch you're on.
ls .git/refs/heads dark main cat .git/refs/heads/main f63a17af33cd97f30d014023639480f94ef09578 cat .git/HEAD ref: refs/heads/main
Everything makes sense now
Now everything fits together. Creating a branch writes one small file. Committing writes new objects, and moves the branch file to the new hash. Switching branches changes the head file. And a tag is just like a branch that never moves.
Summary
A branch is a file holding a hash, and head says which branch you're on. That's the whole trick. Next, publishing your site for free with GitHub.
Key takeaways- Branch = file with a hash
- HEAD = which branch
- Cheap and fast