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 rebase a branch.
And you find out you can also rebase 2 branches simultaneously.

A Glimpse of the Revset Language

With Git you are probably used to rebasing whole branches. Jujutsu's rebase makes no assumptions about what you want to move.

You already saw how to rebase a single Change; you can just as easily move multiple Changes, even sparse ones across different branches: just specify them. For example:

jj rebase -r X -r Y -o O

would move both X and Y on top of O.
Instead of listing Changes one by one, you can use expressions in the Revset Language. Here's a foretaste:

NotationMeaning
X | YAll the Changes in set X plus all the Changes in the set Y
X & YThe Changes that are both in the set X and the set Y
~XChanges that are not in X.
X::X and all its descendants.
::XX and all its predecessors.
X::YAll the Changes between X and Y.

Each expression returns a set, so you can keep combining them into more complex ones.

Moving Sets of Changes

Say that for whatever reason, you want to move the license (Change yz) and the manual (Changes kx and o) on top of main.

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

Solution

It's either:

jj rebase -r yz -r kx -r o -o zx

or:

jj rebase -r "yz | kx | o" -o zx

If you did it right, cool! Pause a second and think how you would get to the same result in Git. It's technically possible, sure, but would you call it straightforward?

Before moving to the next exercise, just:

jj undo

this last move, please.