Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Merge

Goal

In which you learn there is no merge command, and yet you will merge two branches.

A couple pages ago I teased you with a puzzle: you've mastered creating branches of empty commits; but how do you merge them?

Say you want to merge zx with o, and go from:

○  zx           Click alternates Xs and Os main
○  v            Click sets a X
○  s            Square has state
│
│ ○  o          Play instructions
│ ○  kx         Play manual
├─╯
○  n            Square is interactive
│
~

to:

@    vz          Here's the merge
├─╮
│ ○  o          Play instructions
│ ○  kx         Play manual
○ │  zx         Click alternates Xs and Os main
○ │  vv         Click sets a X
○ │  s          Square has state
├─╯
○  n            Square is interactive
│
~

Hint

Remember, if you want to add a Change on top of X you run:

jj new -r X

The -r X part actually means:

Hey, Jujutsu! Create a new Change, having X as its parent.

Another hint

Most of the commits have just 1 parent.
All merge commits have something special in common.

Solution

Sure, a merge commit is nothing but a new commit having 2 parents!
Therefore, to give the new Change 2 parents, simply pass both with -r. In this specific case:

jj new -r o -r zx -m "Here's the merge"

If you got it, kudos. That wasn't an easy one!