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

Mistakes in Past Changes

This is a surprisingly common scenario: the fix lies in editing a conflict-free Change that wasn’t even rebased.

Use Case

○  h
○  g     <- Function rename here
│ ○  f     <- Original function name used in this branch
│ ○  e
│ ○  d
│ ○  c
├─╯
○  b
○  a
◆

Throughout c::f, the code uses foo().
g renames foo() to bar(), making itself incompatible with c::f.

  • You rebase.
jj rebase -s c -o h
  • Conflicts!
×  f
×  e
×  d
×  c     <- Conflict on the function name
○  h
○  g     <- Function rename here
○  b
○  a
◆
  • You realize the conflict originates from the function rename in g.
  • You decide you don’t want that new function name after all.

Solution

Jujutsu doesn’t restrict your edits to the conflicting Changes. Sometimes conflicts can be resolved from a distance.

  • Identify the Change with the unwanted edit (g).
  • Edit it:
jj new -g
sed -i 's/bar/foo/g' file.py
jj squash
  • The conflicts disappear:
○  f
○  e
○  d
○  c     <- No more conflicts
○  h
○  g     <- Back to the old name
○  b
○  a
◆