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 Around

Goal

Where you learn to send a file back to the past.

Changes and Edits

A Change contains your modifications to files such as adding a class, renaming a function, and the like. You can see them as the diff shown by jj show (use --git if you want to use the Git format):

$ jj show rt --git
Commit ID: ad4aa4890ec32cf83c51a407a099afaf9af106b9
Change ID: rtsytxmrmouvklxkuuvqxolokmmkzssz
Author   : Arialdo <arialdo@ik.me> (2026-06-13 19:05:31)
Committer: Arialdo <arialdo@ik.me> (2026-06-15 08:10:28)

    Link to CSS

diff --git a/public/index.html b/public/index.html
index efd73153a2..fd6a1cbbfe 100644
--- a/public/index.html
+++ b/public/index.html
@@ -4,6 +4,7 @@
     <meta charset="UTF-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <title>Document</title>
+    <link rel="stylesheet" href="index.css">
   </head>
   <body>
     <div id="root"></div>

The Jujutsu manual calls them "changes", but that term is already overloaded. Let me call them "edits" from now on, OK?

Finding the Source of a Typo

To narrow down jj log to some files, you can use the Revset Language function files(). Here's the change history of README.md:

$ jj log -r "files('README.md')"

○  kk           Displays X X
~  (elided revisions)
○  rx           Scaffold application
│
~

As you see, README.md was created in rx and modified in kk. Inspect what kk is about:

$ jj show kk --git

diff --git a/README.md b/README.md
index d8ce899bb8..ec822c4346 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,3 @@
-# Learning Raect.js
+# Learning React.js

diff --git a/src/App.js b/src/App.js
index 3f8dbe3702..495f426244 100644
--- a/src/App.js
...

Uh oh! Together with a change to the JavaScript code in App.js, there's also a little fix to the word React.js in README.md. If you check the content of rx, you will see it's the one that introduced the typo:

$ jj file show -r rx README.md
# Learning Raect.js

Following the tutorial at https://react.dev/learn/tutorial-tic-tac-toe

So, it must have gone like this:

  • I wrote the typo Raect instead of React in rx.
  • I missed that so I kept building on top of that.
  • Then, while I was coding App.js I stumbled upon the typo.
  • Instead of fixing it by amending rx, I created a Change, kk, mixing the typo fix with other unrelated changes.

Silly me...
How to move the fix Raect.js -> React.js from kk to rx?

This is really about moving edits.

Sending Fixes Back to the Past

Rebase won't help here: you don't want to move the Change kk, but the edits it contains.
Enter squash. If you are familiar with git merge --squash and the git rebase --interactive's squash command, you know that squashing in Git is about combining multiple commits into a single one.

jj squash generalizes this concept. Think of it as a way to transfer edits from one Change to another. Though these concepts may seem unrelated, Jujutsu's squash is general enough to cover both. The basic syntax is:

jj squash --from A --into B [FILES]

or more concisely:

jj squash -f A -t B [FILES]

The net effect: the edits to [FILES] move from A to B. Your edits stay the same; only which Change owns them differs.

So, fixing my mess with Raect.js is a matter of running:

Solution

$ jj squash -f kk -t rx README.md

Yes, of course! Bravo!

Check the content of kk:

$ jj show --summary kk

Commit ID: 3c72f2573cc5235622030aac110e884014e8ec6b
Change ID: kkqvwlzrztzvlmtyqksulvyuwsorpppx
Author   : Arialdo <arialdo@ik.me> (2026-06-10 14:02:12)
Committer: Arialdo <arialdo@ik.me> (2026-06-15 14:50:39)

    Displays X X

M src\App.js

README.md is not listed anymore. Indeed, in rx the typo is gone:

$ jj file show -r rx README.md
# Learning React.js

Following the tutorial at https://react.dev/learn/tutorial-tic-tac-toe

because the typo fix has been absorbed by the edits already there.

Cool! Next time you are focused on some development task and you find a typo in an unrelated file, you can fix it on the spot and then send it back to the past, where it belongs.