Skip to Content
Navigation:

A stick figure smiling

If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!

Image of a comic. To read the full HTML alt text, click "read the transcript".

browse more comics! get the zine!
read the transcript!

HEAD isn’t always a branch

it can be a commit instead

git checkout a3ffab9

(a3ffab9 isn’t a branch!)

git calls this “detached HEAD state”

by itself, HEAD being a commit ID is okay

Illustration of a smiling stick figure with curly hair.

person: it’s a great way to look at an old version of your code! I do it all the time!

the only problem is that new commits you make will be orphaned

Diagram of a series of circles connected by lines, labelled “main”. The first circle is labelled HEAD. There is a dotted line branching off HEAD to an additional circle. The additional circle is labelled “new commit will go here, danger! it won’t be on any branch!”

some ways HEAD can become a commit ID

git checkout a3ffab3
(a3ffab3 is the commit id)

git checkout origin/main
(origin/main is the “remote-tracking branch”)

git checkout v1.3
(v1.3 is a tag)

if you accidentally create some orphaned commits, it’s SUPER easy to fix

just create a new branch!

git switch -c newbranch

panel 6: my shell prompt tells me if HEAD is a commit

~/work (d63b29) $

d63b29 tells me to avoid creating new commits

(no git commit, git merge, or git rebase)

This is a page from a zine on git I'm currently writing. To get an email when the zine comes out, sign up for our announcements list:

Saturday Morning Comics!

Want another comic like this in your email every Saturday? Sign up here!

I'll send you one of my favourite comics from my archives every Saturday.
© Julia Evans 2024 | All rights reserved (see the FAQ for notes about licensing)