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!

commits in git are usually saved forever

Except! Orphaned commits are deleted periodically.

Illustration of a little garbage can.

Commits are orphaned when you:

  • git commit --amend
  • git rebase
  • delete a branch that hasn’t been merged

what is an orphaned commit?

it’s a commit that isn’t in the history of any branch

they’re almost totally invisible, since Git will usually only show you commits on branches

orphan #1: git commit --amend

before:
An illustration for a box that says parent, with a line to a second box that says fix color buug (typo!). The second box is labelled main branch.

after:
The same diagram as above, but there is now a second line coming out of the parent box, going to a third box that says fix color bug. The fix color buug box is now labelled “now it’s an orphan!” and the fix color bug box is labelled “main branch”.

orphan #2: git rebase

before:
A box with two branches coming out of it. The top one is labelled “main branch”. The second branch has two boxes, one with a heart, and one with a star. This branch is labelled “feature branch”.

after:
A box with two branches coming out of it. The top branch consists of three boxes, one blank, one with a heart, and one with a star. The blank box is labelled “main branch”, and the box with the star is labelled “feature branch”. The second branch consists of two boxes, one with a heart, and one with a star. This branch is labelled “now these two are orphans!”

orphan #3: deleting unmerged branch

before:
A box with two branches coming out of it. The first branch consists of one blank box, labelled “main branch”. The second branch consists of two boxes, one with a heart, and one with a star. This branch is labelled “feature branch”.

after deleting feature:
The same diagram as above, except that the second branch is now labelled “now these two are orphans!”

how to find orphan commits

the only way to find them is with git reflog (or by memorizing their commit ID somehow)

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)