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

Where you learn that rebasing is not necessarily moving a branch to a different base.
Indeed, you will move 1 single Change inserting it in the middle of the history tree.

Moving Changes

rebase works like this:

  • you specify which Changes you want to move
  • and where you want to move them.

Simply:

rebase -r X -o Y

moves the Change X on top of Y. You can also specify the destination using the same --before / -B and --after / -A options you used with jj new.

You'll find the sample repository has many mistakes and unfinished work. I will invite you to fix all the problems in the next exercises.

First, the License

Oh, no! I've added the license to the repository a bit too late, in the Change yz:

  @  x        empty
  ○  zx       Click alternates Xs and Os main
  ○  v        Click sets a X
  ○  s        Square has state
  │ ○  o        Play instructions
  │ ○  kx       Play manual
  ├─╯
  ○  n        Square is interactive
  ○  ru       Board() invokes Square()
  ├─╮
  ○ │  ym       fix name: Square -> Board
  ○ │  x        WIP delete me
  ○ │  yz       LICENSE
  ○ │  ws       A board full of X
  ├─╯
  ○  kk       Displays X X
  ○  wx       Fails
  ○  rx       Scaffold applicatio
  ◆  zz   🔒  empty

$ jj show --summary yz
  Commit ID: 997391344e0b704d8ad78a51e8b9d8c367dc6998
  Change ID: yzxvwmnznuxqpsqttxntvzuqzyrtwsww
  Author   : Arialdo <arialdo@ik.me> (2026-06-10 14:08:47)
  Committer: Arialdo <arialdo@ik.me> (2026-06-10 14:09:15)

      LICENSE

  A LICENSE

Ideally, I would add the license as the very first commit. Somehow yz ended up in the middle of a merged branch.
Can you move yz so it becomes the initial commit?

Solution

$ jj rebase -r yz -A zz

or

$ jj rebase -r yz -B rx

Things Committed by Mistake

The Change x has a suspicious message: WIP: delete me. What does it contain?

Solution

$ jj show x --summary
  Commit ID: 22014d7c4604eb00430fe4e7a583e9aaf5afb77e
  Change ID: xxuknwmlponouxznpzmnqxqvrooxttru
  Author   : Arialdo Martini <arialdo.martini@gmail.com> (2026-06-13 15:46:46)
  Committer: Arialdo Martini <arialdo.martini@gmail.com> (2026-06-13 16:09:31)

      WIP delete me

  A node_modules/yaml/LICENSE
  A node_modules/yaml/index.js

Ouch! I really made a mess there, committing node_modules.

How to get rid of it?

Solution

$ jj abandon x

And x is no more.

Why this exercise? It seems unrelated to moving stuff. But Jujutsu did rebase all descendants of x onto yz under the hood.
Moving things doesn't always look like moving things: Jujutsu commands capture your intent, not the underlying operations.

Typos

Now that I notice, there's a typo in rx's message: applicatio instead of application.
How would you fix it?

Solution

Sure, it's:

$ jj desc -r rx -m "Scaffold application"
Rebased 13 descendant commits
Working copy  (@) now at: xxuknwml 770ae789 WIP delete me
Parent commit (@-)      : yzxvwmnz 02b946ad LICENSE

Again: the intent is editing a message. The log message Rebased 13 descendant commits reveals that, under the hood, it's still about moving commits.

Let's see other examples where your intent is really moving Changes.