Skip to content

Commit f1c9243

Browse files
phil-blaingitster
authored andcommitted
git-rebase.txt: add a note about 'ORIG_HEAD' being overwritten
'ORIG_HEAD' is written at the start of the rebase, but is not guaranteed to still point to the original branch tip at the end of the rebase. Indeed, using other commands that write 'ORIG_HEAD' during the rebase, like splitting a commit using 'git reset HEAD^', will lead to 'ORIG_HEAD' being overwritten. This causes confusion for some users [1]. Add a note about that in the 'Description' section, and mention the more robust alternative of using the branch's reflog. [1] https://lore.kernel.org/git/[email protected]/T/#m827179c5adcfb504d67f76d03c8e6942b55e5ed0 Reported-by: Erik Cervin Edin <[email protected]> Signed-off-by: Philippe Blain <[email protected]> Acked-by: Phillip Wood <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c6eec9c commit f1c9243

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Documentation/git-rebase.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ The current branch is reset to `<upstream>` or `<newbase>` if the
3838
`git reset --hard <upstream>` (or `<newbase>`). `ORIG_HEAD` is set
3939
to point at the tip of the branch before the reset.
4040

41+
[NOTE]
42+
`ORIG_HEAD` is not guaranteed to still point to the previous branch tip
43+
at the end of the rebase if other commands that write that pseudo-ref
44+
(e.g. `git reset`) are used during the rebase. The previous branch tip,
45+
however, is accessible using the reflog of the current branch
46+
(i.e. `@{1}`, see linkgit:gitrevisions[7]).
47+
4148
The commits that were previously saved into the temporary area are
4249
then reapplied to the current branch, one by one, in order. Note that
4350
any commits in `HEAD` which introduce the same textual changes as a commit

0 commit comments

Comments
 (0)