HEAD and Branches
Where you are.
Remember head? It means you are here. When you switch branches, head moves to the branch you switched to. And when you commit, only that branch moves forward.

- HEAD means you are here
- Switching moves HEAD
- Committing moves your branch
Following HEAD
Here, main and dark both point to the same commit, and head is on main. We switch to dark, and head moves over. Now we commit. Only dark moves forward, carrying head with it. Main stays exactly where it was.
Proving it
Let's prove it in the terminal. On branch dark, we write a dark style file, add it, and commit it. Now switch back to main, and list the files. The dark style file isn't here. It only exists on the dark branch. Switch to dark again, and it's back.
git switch -c dark Switched to a new branch 'dark' echo "body { background: black; }" > dark.css git add dark.css git commit -m "Add dark theme" [dark 8d00b30] Add dark theme 1 file changed, 1 insertion(+) create mode 100644 dark.css git switch main Switched to branch 'main' ls about.html index.html style.css git switch dark Switched to branch 'dark' ls about.html dark.css index.html style.css
Summary
Head follows you as you switch, and only the branch you're on moves when you commit. Each branch has its own version of the files. Next, real work on a branch.
Key takeaways- HEAD moves when you switch
- Only your branch moves on commit
- Files change per branch