Skip to content

Commit ff90546

Browse files
peffspearce
authored andcommitted
git-rebase: document suppression of duplicate commits
git-rebase uses format-patch's --ignore-if-in-upstream option, but we never document the user-visible behavior. The example is placed near the top of the example list rather than at the bottom because it is: a. a simple example b. a reasonably common scenario for many projects (mail some patches which get accepted upstream, then rebase) [sp: Corrected direction of 'HEAD..<upstream>' set comparsion] Signed-off-by: Jeff King <[email protected]> Signed-off-by: Shawn O. Pearce <[email protected]>
1 parent 5040bef commit ff90546

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

Documentation/git-rebase.txt

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ The current branch is reset to <upstream>, or <newbase> if the
2828
`git reset --hard <upstream>` (or <newbase>).
2929

3030
The commits that were previously saved into the temporary area are
31-
then reapplied to the current branch, one by one, in order.
31+
then reapplied to the current branch, one by one, in order. Note that
32+
any commits in HEAD which introduce the same textual changes as a commit
33+
in HEAD..<upstream> are omitted (i.e., a patch already accepted upstream
34+
with a different commit message or timestamp will be skipped).
3235

3336
It is possible that a merge failure will prevent this process from being
3437
completely automatic. You will have to resolve any such merge failure
@@ -62,6 +65,26 @@ would be:
6265
The latter form is just a short-hand of `git checkout topic`
6366
followed by `git rebase master`.
6467

68+
If the upstream branch already contains a change you have made (e.g.,
69+
because you mailed a patch which was applied upstream), then that commit
70+
will be skipped. For example, running `git-rebase master` on the
71+
following history (in which A' and A introduce the same set of changes,
72+
but have different committer information):
73+
74+
------------
75+
A---B---C topic
76+
/
77+
D---E---A'---F master
78+
------------
79+
80+
will result in:
81+
82+
------------
83+
B'---C' topic
84+
/
85+
D---E---A'---F master
86+
------------
87+
6588
Here is how you would transplant a topic branch based on one
6689
branch to another, to pretend that you forked the topic branch
6790
from the latter branch, using `rebase --onto`.

0 commit comments

Comments
 (0)