Skip to content
Objects

What a branch is

Forty bytes in a file. That is the entire feature.

A branch is a file containing one object id. Creating one writes forty bytes; deleting one removes them. Nothing is copied, nothing is duplicated, and the size of the history is irrelevant.

This is why branching in git is instant when it was slow in older tools, and why deleting a branch does not delete any commits — it only removes a name that was pointing at one.

HEAD is one more level of the same idea: usually a pointer to a branch, which is a pointer to a commit. When it points straight at a commit instead, that is a detached HEAD.

Commands in this lesson

git branch
List, create or delete the names that point at commits
git checkout
Move HEAD, or restore files — the older command that does both jobs
git switch
Move HEAD to another branch, and with -c create it first
No account, no backend. Everything you do stays in this browser.liter8.sh