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 to send edits to the future, and to split a Change in 2.

Moving Edits To The Future

You saw how to send an edit back to a past Change. In fact, there is nothing in the --from and --into options of jj squash that constrains their position in the history tree. You can send edits to the past, to the future, even to unrelated branches.
But why would you send edits to the future?

A common use case is the following. Inspect the Change rv: it contains 2 unrelated edits, one to CSS and one to the logic:

○  kt   empty Hover effect to board squares
○  rv   Changes to both CSS and app.js
○  q    Add the CSS file css
~

How would you split that Change in two? A possible approach is:

  • To create a Change after rv.
  • To move part of the edits of rv in that future Change.

Come on, try it yourself. Split the CSS edits from the app.js edits into 2 separate Changes:

Solution

$ jj desc -r rv -m "Changes to CSS only"
$ jj new -A rv -m "Changes to app.js only"
$ jj squash -f @- -i

Split

This move is so common that Jujutsu offers a macro command: jj split. It is equivalent to creating a new Change, either after (-A) or before (-B), and then running a jj squash -i.

jj undo the previous move and do it again with jj split.