.ie \n(.g .ds Aq \(aq .el .ds Aq ' .TH jj-rebase 1 "rebase " .SH NAME jj\-rebase \- Move revisions to different parent(s) .SH SYNOPSIS \fBjj rebase\fR [\fB\-b\fR|\fB\-\-branch\fR] [\fB\-s\fR|\fB\-\-source\fR] [\fB\-r\fR|\fB\-\-revisions\fR] [\fB\-d\fR|\fB\-\-destination\fR] [\fB\-A\fR|\fB\-\-insert\-after\fR] [\fB\-B\fR|\fB\-\-insert\-before\fR] [\fB\-\-skip\-emptied\fR] [\fB\-R\fR|\fB\-\-repository\fR] [\fB\-\-ignore\-working\-copy\fR] [\fB\-\-ignore\-immutable\fR] [\fB\-\-at\-operation\fR] [\fB\-\-debug\fR] [\fB\-\-color\fR] [\fB\-\-quiet\fR] [\fB\-\-no\-pager\fR] [\fB\-\-config\fR] [\fB\-\-config\-file\fR] [\fB\-h\fR|\fB\-\-help\fR] .SH DESCRIPTION Move revisions to different parent(s) .PP This command moves revisions to different parent(s) while preserving the changes (diff) in the revisions. .PP There are three different ways of specifying which revisions to rebase: .PP * `\-\-source/\-s` to rebase a revision and its descendants * `\-\-branch/\-b` to rebase a whole branch, relative to the destination * `\-\-revisions/\-r` to rebase the specified revisions without their descendants .PP If no option is specified, it defaults to `\-b @`. .PP There are three different ways of specifying where the revisions should be rebased to: .PP * `\-\-destination/\-d` to rebase the revisions onto the specified targets * `\-\-insert\-after/\-A` to rebase the revisions onto the specified targets and to rebase the targets\*(Aq descendants onto the rebased revisions * `\-\-insert\-before/\-B` to rebase the revisions onto the specified targets\*(Aq parents and to rebase the targets and their descendants onto the rebased revisions .PP See the sections below for details about the different ways of specifying which revisions to rebase where. .PP 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. .PP ### Specifying which revisions to rebase .PP With `\-\-source/\-s`, the command rebases the specified revision and its descendants onto the destination. For example, `jj rebase \-s M \-d O` would transform your history like this (letters followed by an apostrophe are post\-rebase versions): .PP ```text O N\*(Aq | | | N M\*(Aq | | | | M O | | => | | | L | L | |/ | | | K | K |/ |/ J J ``` .PP Each revision passed to `\-s` will become a direct child of the destination, so if you instead run `jj rebase \-s M \-s N \-d O` (or `jj rebase \-s \*(Aqall:M|N\*(Aq \-d O`) in the example above, then N\*(Aq would instead be a direct child of O. .PP With `\-\-branch/\-b`, the command rebases the whole "branch" containing the specified revision. A "branch" is the set of revisions that includes: .PP * the specified revision and ancestors that are not also ancestors of the destination * all descendants of those revisions .PP In other words, `jj rebase \-b X \-d Y` rebases revisions in the revset `(Y..X)::` (which is equivalent to `jj rebase \-s \*(Aqroots(Y..X)\*(Aq \-d Y` for a single root). For example, either `jj rebase \-b L \-d O` or `jj rebase \-b M \-d O` would transform your history like this (because `L` and `M` are on the same "branch", relative to the destination): .PP ```text O N\*(Aq | | | N M\*(Aq | | | | M | L\*(Aq | | => |/ | | L K\*(Aq | |/ | | K O |/ | J J ``` .PP With `\-\-revisions/\-r`, the command rebases only the specified revisions onto the destination. Any "hole" left behind will be filled by rebasing descendants onto the specified revisions\*(Aq parent(s). For example, `jj rebase \-r K \-d M` would transform your history like this: .PP ```text M K\*(Aq | | | L M | | => | | K | L\*(Aq |/ |/ J J ``` .PP Multiple revisions can be specified, and any dependencies (graph edges) within the set will be preserved. For example, `jj rebase \-r \*(AqK|N\*(Aq \-d O` would transform your history like this: .PP ```text O N\*(Aq | | | N K\*(Aq | | | | M O | | => | | | L | M\*(Aq | |/ |/ | K | L\*(Aq |/ |/ J J ``` .PP `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. .PP Note that you can create a merge revision by repeating the `\-d` 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 \-d K \-d M`: .PP ```text M L\*(Aq | |\\ | L M | | | => | | | K | K |/ |/ J J ``` .PP ### Specifying where to rebase the revisions .PP With `\-\-destination/\-d`, the command rebases the selected revisions onto the targets. Existing descendants of the targets will not be affected. See the section above for examples. .PP With `\-\-insert\-after/\-A`, the selected revisions will be inserted after the targets. This is similar to `\-d`, but if the targets have any existing descendants, then those will be rebased onto the rebased selected revisions. .PP For example, `jj rebase \-r K \-A L` will rewrite history like this: ```text N N\*(Aq | | | M | M\*(Aq |/ |/ L => K\*(Aq | | | K L |/ | J J ``` .PP 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: ```text M L\*(Aq | | L K\*(Aq | => | K M\*(Aq | | J J ``` .PP 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\*(Aq parents, and then rebasing the target revisions and their descendants onto the rebased revisions. .PP For example, `jj rebase \-r K \-B L` will rewrite history like this: ```text N N\*(Aq | | | M | M\*(Aq |/ |/ L => L\*(Aq | | | K K\*(Aq |/ | J J ``` .PP 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 \-d L \-d K` might be simpler in this particular case): ```text M M\*(Aq | |\\ L L | | => | | | K | K\*(Aq |/ |/ J J ``` .PP To insert a commit inside an existing merge with `jj rebase \-r O \-A K \-B M`: ```text O N\*(Aq | |\\ N | M\*(Aq |\\ | |\\ | M | O\*(Aq| | | => |/ / | L | L | | | | K | K | |/ |/ J J ``` .SH OPTIONS .TP \fB\-b\fR, \fB\-\-branch\fR=\fIREVSETS\fR Rebase the whole branch relative to destination\*(Aqs ancestors (can be repeated) `jj rebase \-b=br \-d=dst` is equivalent to `jj rebase \*(Aq\-s=roots(dst..br)\*(Aq \-d=dst`. If none of `\-b`, `\-s`, or `\-r` is provided, then the default is `\-b @`. .TP \fB\-s\fR, \fB\-\-source\fR=\fIREVSETS\fR 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 @`. .TP \fB\-r\fR, \fB\-\-revisions\fR=\fIREVSETS\fR Rebase the given revisions, rebasing descendants onto this revision\*(Aqs 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 @`. .TP \fB\-d\fR, \fB\-\-destination\fR=\fIREVSETS\fR The revision(s) to rebase onto (can be repeated to create a merge commit) .TP \fB\-A\fR, \fB\-\-insert\-after\fR=\fIREVSETS\fR The revision(s) to insert after (can be repeated to create a merge commit) .TP \fB\-B\fR, \fB\-\-insert\-before\fR=\fIREVSETS\fR The revision(s) to insert before (can be repeated to create a merge commit) .TP \fB\-\-skip\-emptied\fR 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 .TP \fB\-R\fR, \fB\-\-repository\fR=\fIREPOSITORY\fR Path to repository to operate on By default, Jujutsu searches for the closest .jj/ directory in an ancestor of the current working directory. .TP \fB\-\-ignore\-working\-copy\fR Don\*(Aqt snapshot the working copy, and don\*(Aqt update it By default, Jujutsu snapshots the working copy at the beginning of every command. The working copy is also updated at the end of the command, if the command modified the working\-copy commit (`@`). If you want to avoid snapshotting the working copy and instead see a possibly stale working\-copy commit, you can use `\-\-ignore\-working\-copy`. This may be useful e.g. in a command prompt, especially if you have another process that commits the working copy. Loading the repository at a specific operation with `\-\-at\-operation` implies `\-\-ignore\-working\-copy`. .TP \fB\-\-ignore\-immutable\fR Allow rewriting immutable commits By default, Jujutsu prevents rewriting commits in the configured set of immutable commits. This option disables that check and lets you rewrite any commit but the root commit. This option only affects the check. It does not affect the `immutable_heads()` revset or the `immutable` template keyword. .TP \fB\-\-at\-operation\fR=\fIAT_OPERATION\fR 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=` to see what the repo looked like at an earlier operation. For example `jj \-\-at\-op= st` will show you what `jj st` would have shown you when the given operation had just finished. `\-\-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. When loading the repo at an earlier operation, the working copy will be ignored, as if `\-\-ignore\-working\-copy` had been specified. 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\*(Aqs rarely a reason to do that, but it is possible. .TP \fB\-\-debug\fR Enable debug logging .TP \fB\-\-color\fR=\fIWHEN\fR When to colorize output .br .br [\fIpossible values: \fRalways, never, debug, auto] .TP \fB\-\-quiet\fR Silence non\-primary command output For example, `jj file list` will still list files, but it won\*(Aqt tell you if the working copy was snapshotted or if descendants were rebased. Warnings and errors will still be printed. .TP \fB\-\-no\-pager\fR Disable the pager .TP \fB\-\-config\fR=\fINAME=VALUE\fR 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 doesn\*(Aqt contain any TOML constructs (such as array notation), quotes can be omitted. .TP \fB\-\-config\-file\fR=\fIPATH\fR Additional configuration files (can be repeated) .TP \fB\-h\fR, \fB\-\-help\fR Print help (see a summary with \*(Aq\-h\*(Aq)