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!

ways to reconcile two diverged branches

Illustration of a sequence of boxes joined with lines. The first box is a star, the second box is a heart, and then it branches out into two boxes, one with a hash symbol and one with a squiggle. Hash symbol box is labelled “local main” and squiggle box is labelled “remote main”

  • combine the changes from both with (1) rebase or (2) merge!
  • throw out your local changes (3) after breaking your local branch!
  • throw out the remote changes (4) to get rid of something you accidentally pushed (be REAL careful with this one)

1. rebase

git pull --rebase
git push

Illustration of four boxes (star, heart, squiggle, hash) in a straight line, labelled “local main” and “remote main”

Illustration of a tiny little smiling stick figure with puffy hair in the corner of the panel.

person: this one’s my favourite!

2. merge

git pull --no-rebase
git push

Illustration of two boxes (star and heart) that then diverge into two branches (hash and squiggle) then reconvene into a fifth box, with a diamond in it, labelled “local main” and “remote main”

3. throw away local changes

git switch -c newbranch
git switch main
git reset --hard origin/main

(the first line is labelled “optional: save your changes on main to newbranch so they’re not orphaned)

Illustration of two boxes (star and heart) that then diverge into two branches (hash and squiggle), which are labelled “new branch” and “local main, remote main” respectively.

4. throw away remote changes (DANGER!)

git push --force

Illustration of two boxes (star and heart) that then diverge into two branches one with a hash symbol, labelled “local main, remote main”, and one with a squiggle, whose box is a dotted line, and that’s labelled “orphan”.

(--force is always dangerous, --force-with-lease is a little safer)

reasons to throw away changes

  • I’ll throw away local changes if I accidentally committed to main instead of a new branch

  • I’ll throw away remote changes if I want to amend a commit after pushing it, and I’m the only one working on that branch

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)