jj-rebase(1)

πŸ“¦
version 0.46.0 Β· 2 versions
, in arch rolling, nixpkgs unstable

✨ jj-rebase(1) ✨

General Commands Manual β€” okay bestie, this is the jj-rebase page, and it's literally about moving revisions to different parent(s) πŸ’…


πŸ’– NAME πŸ’–

jj-rebase β€” move revisions to different parent(s) πŸŽ€


🌸 SYNOPSIS 🌸

the whole vibe check in one block, no cap:

jj rebase [-b|--branch] [-R|--repository] [--ignore-working-copy]
[-s|--source] [--no-integrate-operation] [-r|--revision]
[--ignore-immutable] [--at-operation] [--debug] [--color]
[--skip-emptied] [--keep-divergent] [--quiet] [--no-pager]
[--simplify-parents] [--config] [--config-file] [-h|--help]
<--onto|--insert-after|--insert-before>

πŸ¦‹ DESCRIPTION πŸ¦‹

Move revisions to different parent(s). periodt πŸ’–

okay so this command moves revisions to different parent(s) while preserving the changes (diff) in the revisions. it's giving β€œsame diff, new parent” energy, and we love that for you.

there are three different ways of specifying which revisions to rebase:

  • --source/-s β€” rebase a revision and its descendants
  • --branch/-b β€” rebase a whole branch, relative to the destination
  • --revisions/-r β€” rebase the specified revisions without their descendants

if no option is specified, it defaults to -b @. iykyk ✨

there are three different ways of specifying where the revisions should be rebased to:

  • --onto/-o β€” rebase the revisions onto the specified targets
  • --insert-after/-A β€” rebase the revisions onto the specified targets and to rebase the targets' descendants onto the rebased revisions
  • --insert-before/-B β€” rebase the revisions onto the specified targets' parents and to rebase the targets and their descendants onto the rebased revisions

see the sections below for details about the different ways of specifying which revisions to rebase where. we're getting into it, bestie 🫢

🚨 lowkey important: if a working-copy revision gets abandoned, it will be given a new, empty revision. this is true in general; it is not specific to this command.

πŸŽ€ Specifying which revisions to rebase πŸŽ€

with --source/-s, the command rebases the specified revision and its descendants to the destination. for example, jj rebase -s M -o O would transform your history like this (letters followed by an apostrophe are post-rebase versions):

O           N'
|           |
| N         M'
| |         |
| M         O
| |    =>   | |
| L       | L
| |/        | |
| K         | K
|/          |/
J           J

each revision passed to -s will become a direct child of the destination, so if you instead run jj rebase -s M -s N -o O (or jj rebase -s 'M|N' -o O) in the example above, then N' would instead be a direct child of O. the more you know 🌈

with --branch/-b, the command rebases the whole "branch" containing the specified revision. a "branch" is the set of revisions that includes:

  • the specified revision and ancestors that are not also ancestors of the destination
  • all descendants of those revisions

in other words, jj rebase -b X -o Y rebases revisions in the revset (Y..X):: (which is equivalent to jj rebase -s 'roots(Y..X)' -o Y for a single root). for example, either jj rebase -b L -o O or jj rebase -b M -o O would transform your history like this (because L and M are on the same "branch", relative to the destination):

O           N'
|           |
| N         M'
| |         |
| M         L'
| |    =>   |/
| L       K'
| |/        |
| K         O
|/          |
J           J

with --revisions/-r, the command rebases only the specified revisions to the destination. any "hole" left behind will be filled by rebasing descendants onto the specified revisions' parent(s). for example, jj rebase -r K -o M would transform your history like this:

M          K'
|          |
| L        M
| |   =>   | |
| K       | L'
|/         |/
J          J

multiple revisions can be specified, and any dependencies (graph edges) within the set will be preserved. for example, jj rebase -r 'K|N' -o O would transform your history like this:

O           N'
|           |
| N         K'
| |         |
| M         O
| |    =>   | |
| L       | M'
| |/        |/
| K         | L'
|/          |/
J           J

jj rebase -s X is similar to jj rebase -r X:: and will behave the same if X is a single revision. however, if X is a set of multiple revisions, or if you passed multiple -s arguments, then jj rebase -s will make each of the specified revisions an immediate child of the destination, while jj rebase -r will preserve dependencies within the set. this is the tea β˜•πŸ’…

note that you can create a merge revision by repeating the -o argument. for example, if you realize that revision L actually depends on revision M in order to work (in addition to its current parent K), you can run jj rebase -s L -o K -o M:

M          L'
|          |\
| L        M
| | |   => | | |
| K        | K
|/         |/
J          J

πŸ’… Specifying where to rebase the revisions πŸ’…

with --onto/-o, the command rebases the selected revisions onto the targets. existing descendants of the targets will not be affected. see the section above for examples.

with --insert-after/-A, the selected revisions will be inserted after the targets. this is similar to -o, but if the targets have any existing descendants, then those will be rebased onto the rebased selected revisions.

for example, jj rebase -r K -A L will rewrite history like this:

N           N'
|           |
| M         | M'
|/          |/
L        => K'
|           |
| K         L
|/          |
J           J

the -A (and -B) argument can also be used for reordering revisions. for example, jj rebase -r M -A J will rewrite history like this:

M          L'
|          |
L          K'
|     =>   |
K          M'
|          |
J          J

with --insert-before/-B, the selected revisions will be inserted before the targets. this is achieved by rebasing the selected revisions onto the target revisions' parents, and then rebasing the target revisions and their descendants onto the rebased revisions.

for example, jj rebase -r K -B L will rewrite history like this:

N           N'
|           |
| M         | M'
|/          |/
L        => L'
|           |
| K         K'
|/          |
J           J

the -A and -B arguments can also be combined, which can be useful around merges. for example, you can use jj rebase -r K -A J -B M to create a new merge (but jj rebase -r M -o L -o K might be simpler in this particular case):

M           M'
|           |\
L           L
| |     =>  | | |
| K         | K'
|/          |/
J           J

to insert a commit inside an existing merge with jj rebase -r O -A K -B M:

O           N'
|           |\
N           | M'
|\          | |\
| M         | O'| |
| |    =>   |/ /
| L         | L
| |         | |
| K         | K
| |/        |/
J           J

πŸ‘‘ OPTIONS πŸ‘‘

okay bestie, here's every flag, every default, no skips. we are not leaving anything out πŸ’œ

  • -b, --branch <REVSETS> β€” rebase the whole branch relative to destination's ancestors (can be repeated). jj rebase -b=br -o=dst is equivalent to jj rebase '-s=roots(dst..br)' -o=dst. if none of -b, -s, or -r is provided, then the default is -b @.
  • -s, --source <REVSETS> β€” rebase specified revision(s) together with their trees of descendants (can be repeated). each specified revision will become a direct child of the destination revision(s), even if some of the source revisions are descendants of others. if none of -b, -s, or -r is provided, then the default is -b @.
  • -r, --revision <REVSETS> β€” rebase the given revisions, rebasing descendants onto this revision's parent(s). unlike -s or -b, you may jj rebase -r a revision A onto a descendant of A. if none of -b, -s, or -r is provided, then the default is -b @.
  • -o, --onto <REVSETS> β€” the revision(s) to rebase onto (can be repeated to create a merge commit).
  • -A, --insert-after <REVSETS> β€” the revision(s) to insert after (can be repeated to create a merge commit).
  • -B, --insert-before <REVSETS> β€” the revision(s) to insert before (can be repeated to create a merge commit).
  • --skip-emptied β€” if true, when rebasing would produce an empty commit, the commit is abandoned. it will not be abandoned if it was already empty before the rebase. will never skip merge commits with multiple non-empty parents.
  • --keep-divergent β€” keep divergent commits while rebasing. without this flag, divergent commits are abandoned while rebasing if another commit with the same change ID is already present in the destination with identical changes.
  • --simplify-parents β€” simplify parents of rebased commits, like jj simplify-parents, while rebasing them. any parents that are ancestors of other parents will be removed.
  • -h, --help β€” print help (see a summary with '-h').

✨ GLOBAL OPTIONS ✨

These are the big-picture flags that work on basically every jj command, and obvs jj rebase is no exception. Learn these once, use them everywhere. iykyk πŸ’…

  • -R, --repository <REPOSITORY> β€” the path to the repo you wanna operate on πŸŽ€

So like, by default Jujutsu goes hunting for the closest .jj/ directory in an ancestor of wherever your current working directory is. That's the default vibe. If your repo is somewhere else, this flag is your bestie.

  • --ignore-working-copy β€” don't snapshot the working copy, and don't update it either πŸ™ˆ

Okay so real talk: by default, Jujutsu snapshots the working copy at the beginning of every command. The working copy also gets updated at the end of the command, but only if the command modified the working-copy commit (@). If you'd rather not snapshot at all and instead see a possibly stale working-copy commit, this is the flag. Lowkey useful in a command prompt, especially when you've got another process committing the working copy behind your back πŸ‘€

Also important: loading the repo at a specific operation with --at-operation implies --ignore-working-copy. So like, they're linked, bestie.
  • --no-integrate-operation β€” run the command as usual but don't integrate any operations πŸ¦‹

When you give this option, the operations will still be created as usual β€” but they won't be integrated into the operation log. The working copy also won't be updated. Sneaky, right?

The command will print the resulting operation ID. You can pass that to e.g. jj --at-op to inspect the resulting repo state, or you can pass it to jj op restore to restore the repo to that state. You can also pass the ID to jj op integrate to integrate the operation. So many doors open ✨

⚠️ Heads up, this does not prevent side effects outside the repo. For example, jj git push --no-integrate-operation will still perform the push. The push is gonna push, periodt.
  • --ignore-immutable β€” allow rewriting immutable commits πŸ‘‘

By default, Jujutsu prevents rewriting commits in the configured set of immutable commits. That's the safety rail, and honestly? Iconic of it. This option disables that check and lets you rewrite any commit but the root commit. Root stays sacred, fr fr.

This option only affects the check. It does not affect the immutable_heads() revset or the immutable template keyword. Just so we're clear 🫢

  • --at-operation <AT_OPERATION> β€” the operation to load the repo at πŸ•°οΈ

Operation to load the repo at. By default, Jujutsu loads the repo at the most recent operation, or at the merge of the divergent operations if any.

You can use --at-op=<operation ID> to see what the repo looked like at an earlier operation. For example, jj --at-op=<operation ID> st will show you what jj st would have shown you when the given operation had just finished. It's giving time travel, honestly. --at-op=@ is pretty much the same as the default except that divergent operations will never be merged.

Use jj op log to find the operation ID you want. Any unambiguous prefix of the operation ID is enough β€” no need to type the whole thing πŸ’–

When loading the repo at an earlier operation, the working copy will be ignored, as if --ignore-working-copy had been specified.

And listen β€” it is possible to run mutating commands when loading the repo at an earlier operation. Doing that is equivalent to having run concurrent commands starting at the earlier operation. There's rarely a reason to do that, but it is possible. So like, you can, but should you? 🌸

  • --debug β€” enable debug logging πŸ“

That's it. That's the whole thing. Debug logging: enabled.

  • --color <WHEN> β€” when to colorize output 🌈

Possible values:

  • always
  • never
  • debug
  • auto
  • --quiet β€” silence non-primary command output 🀫

For example, jj file list will still list files, but it won't tell you if the working copy was snapshotted or if descendants were rebased. It just gets to the point. Very demure.

Warnings and errors will still be printed. The quiet does not silence the important stuff, bestie.
  • --no-pager β€” disable the pager πŸ’€

No pager. None. Output comes at you directly.

  • --config <NAME=VALUE> β€” additional configuration options (can be repeated) πŸŽ€

The name should be specified as TOML dotted keys. The value should be specified as a TOML expression. If string value isn't enclosed by any TOML constructs (such as array notation), quotes can be omitted. Fancy TOML moment, but make it casual ✨

  • --config-file <PATH> β€” additional configuration files (can be repeated) πŸ¦‹

Extra config files, plural, as many as your heart desires.


And that's the whole page, bestie!! 🫢 You made it to the end of jj-rebase(1) β€” every flag, every caveat, every last TOML dotted key. Genuinely obsessed with you for reading the whole thing πŸ’–

This gorgeous little document is the jj-rebase(1) manual page from the Jujutsu (jj) docs β€” that's the source/version bit and the date down at the bottom, all official and everything. Slay. Go rebase something iconic πŸ‘‘βœ¨

πŸ“¦ where this page comes from