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 learn that you can keep working as usual.
  • You will even rebase the conflicted Change and commit on top of it.

Living with Conflicts

Let's see if before resolving the conflict you can rebase the whole branch vr:: from its base q to r:

@  zo       empty Merge conflict
├─╮
│ ○  nz        merge-b
○ │  m         merge-a
├─╯
○  vr       Base of merge-a and merge-b   <- current base
│ ○  y        empty  feat-2
│ ○  vw       empty
│ ○  x        empty
│ ○  vn       empty
│ ○  r        Rebase vr:: here            <- rebase it here
├─╯
│
~

Solution

There are a couple of ways to do this.
You can specify the Changes to rebase with vr:: (vr and all its descendants):

jj rebase -r vr:: -o r

Otherwise, you can specify the cut & paste points, with:

jj rebase -s vr -o r

as you saw in Git Rebase.

The rebase succeeds. Unlike Jujutsu won't whine with something like:

error: cannot rebase: You have unstaged changes.
error: additionally, your index contains uncommitted changes.
error: Please commit or stash them.

or:

fatal: It seems that there is already a rebase-merge directory, and
I wonder if you are in the middle of another rebase.  If that is the
case, please try
        git rebase (--continue | --abort | --skip)
If that is not the case, please
        rm -fr ".git/rebase-merge"
and run me again.  I am stopping in case you still have something
valuable there.

Of course, even if jj rebase succeeded, the conflict is still there, and you will be reminded of that:

Warning: There are unresolved conflicts at these paths:
file.txt    2-sided conflict

But again, it's just a warning, not a showstopper.
Can you even commit on top of a conflicted Change? Of course, why not! Give it a try:

jj new -m "My parent is conflicted"
jj new
echo "I can keep working" > some-work-file.txt
jj squash


@  l        empty
×  zm       My parent is conflicted
×  zo       Merge conflict
├─╮
│ ○  nz        merge-b
○ │  m         merge-a
├─╯
○  vr       Base of merge-a and merge-b
│
~

As you see, Jujutsu won't forget that there is a conflict back in history, so it will keep displaying the warning:

Warning: There are unresolved conflicts at these paths:
file.txt    2-sided conflict

and jj log will highlight all the Changes inheriting that conflict using × and red @ symbols.

Time to resolve the conflict.