7. HEAD says where you are
HEAD points at the branch you are on; a commit's parent is the commit under HEAD and only that branch moves; switching moves HEAD and rewrites the files; HEAD itself is a one-line file naming the branch.

7. HEAD says where you are

HEAD points at the branch you are on; a commit's parent is the commit under HEAD and only that branch moves; switching moves HEAD and rewrites the files; HEAD itself is a one-line file naming the branch.

It explains which branch grows when you commit, and what checkout and switch actually do.

Several notes, one project. Which one are you on? HEAD answers.

HEAD is a marker that points at another note. Usually a branch.

When you commit, the parent is the commit under HEAD. And the branch under HEAD moves. Not the others.

Switching branches moves HEAD to a different note. Then Git rewrites your files to match that commit.

HEAD is itself a small file. Inside is one line: the name of the branch note.

Check yourself. You have branches main and fix. You commit. Which branch moves, and how does Git know?

Do you like what you are reading? Subscribe to receive updates.

Unsubscribe anytime