git/list[1] front-page[2] threads[3] people[4] search[5] about
 

git rebase: retain original head?

From
MWMarkus Wiederkehr <markus.wiederkehr@gmail.com>
Date
Jan 8, 2019, 15:06 UTC
Message-ID
<CA+h-Bnuf6u=hkPBcxhMm06FbfkS+jtrozu+inqqmUY1cNkXrWQ@mail.gmail.com>
Hello,

I frequently run an interactive rebase to change the order of recent commits, apply fixups, etc. When merge conflicts occur I often want to compare the result with the original head prior to starting the rebase.

In the past I used "git diff ORIG_HEAD". This used to work as long as I did not manually invoke "git reset" during the operation.

Since git version 2.20.1 (not sure, maybe 2.20.0?) this no longer works because ORIG_HEAD seems to get modified by fixup commits during rebase. Now I have to search through reflog to find the commit I want to compare the current head to.

During the rebase operation the original head seems to get stored in 'rebase-merge/orig-head'. Unfortunately this references gets removed after the rebase operation completes.

Would it be possible to retain this information? Could you set ORIG_HEAD back to rebase-merge/orig-head after rebase completes? Alternatively, could something like REBASE_HEAD be added for this purpose?

Undoing a rebase would be related to this and is a very popular question on SO [1]. Users recommend using "git reset --hard ORIG_HEAD" which now no longer works.

Regards, Markus

[1] https://stackoverflow.com/questions/134882
Next: Andreas Schwab
Message 1 of 11 in “git rebase: retain original head?”
  1. Markus WiederkehrJan 8, 2019
  2. Andreas SchwabJan 8, 2019
  3. Markus WiederkehrJan 8, 2019
  4. Andreas SchwabJan 8, 2019
  5. Markus WiederkehrJan 9, 2019
  6. Jacob KellerJan 8, 2019
  7. Johannes SchindelinJan 9, 2019
  8. Markus WiederkehrJan 9, 2019
  9. Johannes SchindelinJan 11, 2019
  10. Nazri RamliyFeb 27, 2019
  11. Johannes SchindelinFeb 28, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.