Unmerge
Important
You discover that undoing a merge is trivial.
How do you unmerge?
@ nvn ▢ Here's the merge
├─╮
│ ○ o Play instructions **manual**
│ ○ kx Play manual
○ │ z Click alternates Xs and Os **dev**
○ │ v Click sets a X
○ │ s Square has state
├─╯
│
~
Easy! If merging was your last operation, just use jj undo:
jj undo
○ o Play instructions **manual**
○ kx Play manual
│ ○ z Click alternates Xs and Os **dev**
│ ○ v Click sets a X
│ ○ s Square has state
├─╯
│
~
Unmerging With abandon
Alternatively, you could jj abandon the merge Change. Let’s try it.
First, start over:
jj redo
Yes! As seen in the Quick Start, you can
undo an undo . Jujutsu’s undo works like Emacs’: instead of merely
going back in time, it appends the revert operation to a log. No
information is ever lost. Curious? Read Emacs’
Undo.
You are back to:
@ vz Here's the merge
├─╮
│ ○ o Play instructions instructions **dev**
│ ○ kx Play manual
○ │ z Click alternates Xs and Os **manual**
○ │ vv Click sets a X
○ │ s Square has state
├─╯
~
Do yourself a favor: move somewhere else before deleting the merge, or you’ll abandon your Current Change1:
jj edit n
Your turn.
Warning
Unmerge without using
undo.
Tip
Elementary, my dear Watson!
jj abandon vz○ o Play instructions **manual** ○ kx Play manual │ ○ z Click alternates Xs and Os **dev** │ ○ v Click sets a X │ ○ s Square has state ├─╯ ~
Can you merge more than 2 Changes? Sure! In Git this is called an “octopus merge”: it’s rare enough to be considered an anti-pattern. Jujutsu embraces it, instead. You’ll see fancy workflows based on it.
Warning
Now, create an octopus merge between
css,manualanddev:
Tip
jj new -r css -r manual -r dev@ kn ▢ ├─┬─╮ │ │ ○ z Click alternates Xs and Os **dev** │ │ ○ v Click sets a X │ │ ○ s Square has state │ ○ │ o Play instructions **manual** │ ○ │ kx Play manual │ ├─╯ ○ │ qn Add the CSS file **css** ○ │ rt Link to CSS ├─╯ ~
Too easy? See? You already think like a jujutsuka!
Notice: you merged the tips of 3 branches, but nothing stopped you
from referencing a Change that wasn’t at a branch tip.
In Git, undoing a merge ranges from easy to painful, depending on your experience. Jujutsu makes it trivial regardless.
-
Abandoning the Current Change is perfectly legit, but it might surprise you the first time. Read Pulling the Rug Out Under Oneself for details. ↩