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!

there are 3 options for combining branches

  • merge
  • rebase
  • squash

for example, let’s say we’re combining these 2 branches:

Diagram: A box with a heart. To its right is a box with a star. From here, it branches out into branch 1, which consists of one box with a hash symbol, and branch 2, which consists of a branch with a spiral, followed by a branch with a squiggle.

panel 2:

  1. git rebase
    Diagram: A box with a heart. To its right is a box with a star. From here, it branches out into branch 1, which consists of a box with a hash symbol, followed by a branch with a spiral, then a box with a squiggle. Branch 2 consists of a box with a spiral, followed by a box with a squiggle. Branch 2 is made up of dotted lines and labelled “orphan”.

  2. git merge
    Diagram: A box with a heart. To its right is a box with a star. From here, it branches out into branch 1, which consists of a box with a hash symbol. Branch 2 consists of a box with a spiral, followed by a box with a squiggle. Branches 1 and 2 both lead into a new box, with a diamond.

  3. git merge --squash
    Diagram: A box with a heart. To its right is a box with a star. From here, it branches out into branch 1, which consists of a box with a hash symbol, followed by a new box containing both a squiggle and a spiral. Branch 2 consists of a box with a spiral, followed by a box with a squiggle. Branch 2 is made up of dotted lines and labelled “orphan”.

all 3 methods result in the EXACT SAME FILES

some differences are:

  • the diff git shows you for the final commit
  • the specific flavour of suffering the method causes

merge

pro: if you mess something up, the original commits are still in your branch’s history

pain: when I look at histories like this I feel dread

Diagram: a complicated git history with a number of different branches.

rebase

pro: you can keep your git history simple:

Diagram: a git history that is just a series of boxes in a straight line.

pain: - harder to learn [sad face] - harder to undo [sad face] - easier to mess up [sad face]

(I love rebase though!)

squash

pro: have 20 messy commits? nobody needs to know!
And it’s pretty simple to use.

pain: “ugh, someone squashed their 3000-line branch into 1 commit”

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)