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 Change that is conflict-free and wasn't even rebased.

Use Case

○  h
○  g     <- Function rename here
│ ○  f     <- Original function name used in this branch
│ ○  e
│ ○  d
│ ○  c
├─╯
○  b
○  a
◆
  • 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 g introduced a function rename you didn't mean to keep.

  • You decide that, after all, that function rename isn't something you actually want.

Solution

The idea is that you can change your mind on that function rename: Jujutsu doesn't restrict your edits to the conflicting Changes during conflict resolution. Sometimes conflicts can be resolved from a distance.

  • You identify the Change where the unwanted edit was done (g).

  • You edit it:

$ jj new -g
$ sed -i 's/new_name/old_name/g' file.py
$ jj squash

Alternatively, you can abandon the Change entirely.

  • Conflicts are gone:
○  f
○  e
○  d
○  c     <- No more conflicts
○  h
○  g     <- Back to the old name
○  b
○  a
◆