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

Goal

You see that you already know how to resolve a rebase conflict.

Rebase Conflicts

I bet this chapter will be a mere formality for you. You already know how to resolve a rebase conflict. Don't you think? Challenge yourself. Move the feat-1 branch on top of vr:

○  so
○  o        Merge conflict
├─╮
│ ○  nz        merge-b
○ │  m         merge-a
├─╯
○  vr       Base of merge-a and merge-b base
│ ○  y        empty  feat-2
│ ○  vw       empty
│ ○  x        empty
│ ○  vn       empty
│ ○  r        Rebase vr:: here
├─╯
│ ○  no       empty  feat-1
│ ○  vt       empty
│ ○  sy       empty
│ ○  u        empty
│ ○  vz       empty
├─╯
○  q        empty  main
◆  z    🔒  empty

Solution

If you are on top of the feat-1 branch:

jj new feat-1

then specifying the new base is enough:

jj rebase -o vr

Otherwise, if you rebase from a distance, specify both source and target:

jj rebase -s vz -o vr

Here we go, a conflict in s:

@  no        feat-1
×  vt
×  s        Will conflict
○  u
○  vz
│ ○  y        empty  feat-2
│ ○  vw       empty
│ ○  x        empty
│ ○  vn       empty
├─╯
○  r        Rebase vr:: here
│
~

As you see, the conflict arises in s and is propagated to all descendants.
How to resolve it? Remember to use the jj new && (jj squash || jj restore) workflow you saw in Don't Edit.

Solution

jj new -r s

You will find this conflict in feat-1.js:

<<<<<<< conflict 1 of 1
+++++++ unmwmutn 91e9daba "" (rebase destination)
  // This comment will get a conflict
%%%%%%% diff from: unmwmutn e6f1eb22 "" (parents of rebased revision)
\\\\\\\        to: nolxxptq 09ad5fbc (rebased revision)
+  // Handle theme color and mode
>>>>>>> conflict 1 of 1 ends

A possible resolution is to replace the whole section with:

  // Handle theme color and mode

Then:

jj squash

and you are done!

If you got it right, good job! You will see how the resolution propagate from s all the way down its descendants:

○  no        feat-1
○  vt
○  s        Will conflict
○  u
○  vz
│ ○  y        empty  feat-2
│ ○  vw       empty
│ ○  x        empty
│ ○  vn       empty
│ ○  r        Rebase vr:: here
├─╯
~

See? A walk in the park.