Skip to Content
Navigation:

A stick figure smiling

Here's a preview from my zine, How Git Works! 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:

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 “lost”.

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.

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 has a box with a spiral, followed by a branch with a squiggle.

all 3 methods result in the EXACT SAME FILES

some differences are: - the diff git shows you for the final commit - the commit ids - the specific flavour of suffering the method causes

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!)

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 [sad face]

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

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” [sad face]

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)