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:
| Notation | Meaning |
|---|---|
X | Y | All the Changes in set X plus all the Changes in the set Y |
X & Y | The Changes that are both in the set X and the set Y |
~X | Changes that are not in X. |
X:: | X and all its descendants. |
::X | X and all its predecessors. |
X::Y | All 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
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.