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

Bookmark Conflicts

Important

You sort out situations where two developers move the same Bookmark into incompatible positions.

In general, moving a Bookmark forward usually suceeds. Moving it backwards or sideways to a parallel branch is less natural. Git allows it locally, but rejects the subsequent push complaining the move was non-fast-forward.

Jujutsu anticipates the problem and raise an error before the push, right when you attempt the move.
In theirs, try moving foo from k to o:

jj bookmark move foo --to o
Error: Refusing to move bookmark backwards or sideways: foo
Hint: Use --allow-backwards to allow it.

Better safe than sorry.

Your Coworker Forces Their Way

If you really want to win this fight, you can always use the --allow-backwards parameter.

jj bookmark move foo --to o --allow-backwards
@  sz   (empty)
│ ○  k    Hello, world **foo@origin**
│ ○  st
├─╯
│ ○  o    **bar** **foo***
├─╯
◆  u    **main**
│
~

2 things to notice:

  • Because foo and foo@origin are now on different Changes, Jujutsu displays both.
  • The asterisk in foo* invites your coworker to align.

Indeed, your colleague pushes:

jj git push -b foo
@  sz   (empty)
│ ○  k    Hello, world
│ ○  st
├─╯
│ ○  o    **bar** **foo**
├─╯
◆  u    **main**
│
~

then calls it a day. Bye bye!

What Happens in Your Repository

Back in ours repository. Unaware of your colleague’s move, you keep working on foo, adding another Change:

jj new -m "Hola, mundo"
echo "Hola, mundo" > hello.txt
@  ol   Hola, mundo
○  k    Hello, world **foo**
○  s
│ ○  os   **bar**
├─╯
◆  u    **main**
│
~

and you advance foo to ol:

jj bookmark advance
@  ol   Hola, mundo **foo***
○  k    Hello, world **foo@origin**
○  s
│ ○  os   **bar**
├─╯
◆  u    **main**
│
~

Jujutsu marks foo*, inviting you to push:

jj git push -b foo
Error: Failed to push some bookmarks

Hint: Try fetching from the remote, then make the bookmark point to where 
      you want it to be, and push again.

Rejected.

Conflicts

Here’s the log after you fetch:

@  ol   Hola, mundo **foo??** **foo@git**
○  k    Hello, world
○  s
│ ○  os   **bar** **foo??** **foo@origin**
├─╯
◆  u    main
│
~

Listing bookmarks also helps:

jj bookmark list foo
**foo** (conflicted):
  - ksvskswq 938fe989 Hello, world
  + olnvmuqu 09526447 Hola, mundo
  + ossuomlo fa22ec04 (no description set)
  **@git** (behind by 1 commits): olnvmuqu 09526447 Hola, mundo
  **@origin** (behind by 3 commits): ossuomlo fa22ec04 (no description set)

OK, calm down: there are 4 instances of foo now. How should you interpret the situation?

  • Two foo?? markers (on ol and os) means that the local foo points to both because you wanted it on ol, but origin says it should be on os. Undecided, Jujutsu targets both.
  • foo@git means that, given the unclarity, the Git branch remains on ol.
  • foo@origin shows the last known position in origin.

This can’t be reconciled automatically. You’d better talk to your coworker and clarify what they had in mind.

Resolve a Bookmark Conflict

One possible solution having foo holding both the Changes in ol and those in os is to create a merge Change:

Change:

jj new -r ol -r os -m "Merge"
@    p    (empty) Merge
├─╮
│ ○  os   **bar** **foo??** **foo@origin**
○ │  ol   Hola, mundo **foo??** **foo@git**
○ │  k    Hello, world
○ │  s
├─╯
◆  u    main
│
~

p is a good place to move foo:

jj bookmark move foo -t p
@    p    (empty) Merge **foo***
├─╮
│ ○  os   **bar** **foo@origin**
○ │  ol   Hola, mundo
○ │  k    Hello, world
○ │  s
├─╯
◆  u    **main**
│
~

Lovely! No conflicts anymore, only the invitation to push:

jj git push -b foo
@    p    (empty) Merge **foo**
├─╮
│ ○  os   **bar**
○ │  ol   Hola, mundo
○ │  k    Hello, world
○ │  s
├─╯
◆  u    **main**
│
~

All clear. Your coworker is forgiven.