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

Moving Edits To The Future

Important

You send edits into the future and you split a Change in two.

You saw how to send your work back to a past Change. But nothing was forcing you to look backwards. The --into / -t Change can be anywhere: sideways to unrelated branches, or forwards into the future.
This begs the question: why send things into the future?

A common use case is splitting. You commit, then realize you bundled unrelated edits. Tidying up means pulling them apart into independent, possibly descendants, Changes.

See rx:

○  rx       Scaffold application
○  yz       LICENSE
◆  zz   🔒  ▢

It contains the scaffold application plus the README file:

jj show -r rx --summary
A .gitignore
A README.md            <-- isolate this
A package-lock.json
A package.json
A public/index.html
A src/App.js
A src/index.js
A src/styles.css

Say that you want to have the README file first, the application right next. You could split rx in two, like this:

  • You create a Change after rx.
  • You move part of rx’s edits into that future Change.

Try it yourself.

Warning

Split the application and README.md into 2 separate Changes.

Tip

jj new -A rx -m "Scaffold application"
jj desc -r rx -m "README file"
jj squash -f rx -t rx+ -i

Split

This move is so common that Jujutsu offers a macro-command: jj split. It lets you interactively select part of the edits and move the rest to a new child Change, in one shot. Do a jj undo and run:

jj split -r rx -m "README file"

and select the README.md:

○  yo       Scaffold application   <-- the rest, moved to the future
○  rx       README file            <-- what you selected
○  yz       LICENSE
◆  zz   🔒  ▢

If you already know what to select, just specify it directly:

jj split -r rx -m "README file" README.md

Making It Your Workflow

Splitting isn’t just for fixing mistakes. It can be a deliberate move: code first without worrying about history, then easily reshape the result into a tidy, logical series of commits.

In Git, rewriting history is expensive enough that you usually plan upfront. Jujutsu makes cleanup so cheap that you can defer the decision until you’re finished coding.

When done deliberately, this move may become the building block of your next workflow.