Skip to content

Commit 003f815

Browse files
committed
Merge branch 'pw/rebase-keep-base-fixes'
"git rebase --keep-base" used to discard the commits that are already cherry-picked to the upstream, even when "keep-base" meant that the base, on top of which the history is being rebuilt, does not yet include these cherry-picked commits. The --keep-base option now implies --reapply-cherry-picks and --no-fork-point options. * pw/rebase-keep-base-fixes: rebase --keep-base: imply --no-fork-point rebase --keep-base: imply --reapply-cherry-picks rebase: factor out branch_base calculation rebase: rename merge_base to branch_base rebase: store orig_head as a commit rebase: be stricter when reading state files containing oids t3416: set $EDITOR in subshell t3416: tighten two tests
2 parents e5be3c6 + aa1df81 commit 003f815

File tree

6 files changed

+172
-89
lines changed

6 files changed

+172
-89
lines changed

Documentation/git-rebase.txt

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,14 @@ leave out at most one of A and B, in which case it defaults to HEAD.
218218
merge base of `<upstream>` and `<branch>`. Running
219219
`git rebase --keep-base <upstream> <branch>` is equivalent to
220220
running
221-
`git rebase --onto <upstream>...<branch> <upstream> <branch>`.
221+
`git rebase --reapply-cherry-picks --no-fork-point --onto <upstream>...<branch> <upstream> <branch>`.
222222
+
223223
This option is useful in the case where one is developing a feature on
224224
top of an upstream branch. While the feature is being worked on, the
225225
upstream branch may advance and it may not be the best idea to keep
226-
rebasing on top of the upstream but to keep the base commit as-is.
226+
rebasing on top of the upstream but to keep the base commit as-is. As
227+
the base commit is unchanged this option implies `--reapply-cherry-picks`
228+
to avoid losing commits.
227229
+
228230
Although both this option and `--fork-point` find the merge base between
229231
`<upstream>` and `<branch>`, this option uses the merge base as the _starting
@@ -278,7 +280,8 @@ See also INCOMPATIBLE OPTIONS below.
278280
Note that commits which start empty are kept (unless `--no-keep-empty`
279281
is specified), and commits which are clean cherry-picks (as determined
280282
by `git log --cherry-mark ...`) are detected and dropped as a
281-
preliminary step (unless `--reapply-cherry-picks` is passed).
283+
preliminary step (unless `--reapply-cherry-picks` or `--keep-base` is
284+
passed).
282285
+
283286
See also INCOMPATIBLE OPTIONS below.
284287

@@ -311,13 +314,16 @@ See also INCOMPATIBLE OPTIONS below.
311314
upstream changes, the behavior towards them is controlled by
312315
the `--empty` flag.)
313316
+
314-
By default (or if `--no-reapply-cherry-picks` is given), these commits
315-
will be automatically dropped. Because this necessitates reading all
316-
upstream commits, this can be expensive in repos with a large number
317-
of upstream commits that need to be read. When using the 'merge'
318-
backend, warnings will be issued for each dropped commit (unless
319-
`--quiet` is given). Advice will also be issued unless
320-
`advice.skippedCherryPicks` is set to false (see linkgit:git-config[1]).
317+
318+
In the absence of `--keep-base` (or if `--no-reapply-cherry-picks` is
319+
given), these commits will be automatically dropped. Because this
320+
necessitates reading all upstream commits, this can be expensive in
321+
repositories with a large number of upstream commits that need to be
322+
read. When using the 'merge' backend, warnings will be issued for each
323+
dropped commit (unless `--quiet` is given). Advice will also be issued
324+
unless `advice.skippedCherryPicks` is set to false (see
325+
linkgit:git-config[1]).
326+
321327
+
322328
`--reapply-cherry-picks` allows rebase to forgo reading all upstream
323329
commits, potentially improving performance.
@@ -443,9 +449,9 @@ When `--fork-point` is active, 'fork_point' will be used instead of
443449
<branch>` command (see linkgit:git-merge-base[1]). If 'fork_point'
444450
ends up being empty, the `<upstream>` will be used as a fallback.
445451
+
446-
If `<upstream>` is given on the command line, then the default is
447-
`--no-fork-point`, otherwise the default is `--fork-point`. See also
448-
`rebase.forkpoint` in linkgit:git-config[1].
452+
If `<upstream>` or `--keep-base` is given on the command line, then
453+
the default is `--no-fork-point`, otherwise the default is
454+
`--fork-point`. See also `rebase.forkpoint` in linkgit:git-config[1].
449455
+
450456
If your branch was based on `<upstream>` but `<upstream>` was rewound and
451457
your branch contains commits which were dropped, this option can be used

0 commit comments

Comments
 (0)