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

Re: bug?: ORIG_HEAD incorrect after reset during git-rebase -i

From
PWPhillip Wood <phillip.wood@talktalk.net>
Date
Dec 16, 2021, 16:27 UTC
Message-ID
<e6adaad6-f6ee-57d3-dc8f-d14a760c57c2@talktalk.net>
In-Reply-To
<CA+JQ7M-ynq1cLN-3ZodXae=x-H5k7Ab6uPBwUFhG+kgtOvCgtA@mail.gmail.com>
Hi Erik
On 16/12/2021 14:30, Erik Cervin Edin wrote:
> Steps to reproduce:
> 1. git-rebase -i
> 2. edit XYZ
> 3. git-reset HEAD~

"git reset" will update ORIG_HEAD to the current HEAD before resetting so here ORIG_HEAD gets updated to point to XYZ

Show 15 quoted lines
> 4. git-commit -C ORIG_HEAD -a
> 5. git-rebase --continue
> 6. git-show ORIG_HEAD
> 
> Expected behavior:
> ORIG_HEAD should point at the previous HEAD of the rebased branch
> 
> Actual behavior:
> ORIG_HEAD points to XYZ
> 
> My understanding from reading https://stackoverflow.com/a/64949884 is
> that this is incorrect behavior.
> 
> Perhaps this is as intended but I would at least personally prefer
> that ORIG_HEAD would point to the previous HEAD of the rebased branch.

You can use the reflog to get the previous HEAD of the rebased branch after rebasing. Immediately after the rebase branch-name@{1} will point to the pre-rebase HEAD.

Best Wishes
Phillip
Show 5 quoted lines
> Seen in:
> git version 2.31.1.windows.1
> 
> Possibly related to
> e100bea481 - rebase -i: stop overwriting ORIG_HEAD buffer
Previous: Erik Cervin EdinNext: Erik Cervin Edin
Message 2 of 7 in “bug?: ORIG_HEAD incorrect after reset during git-rebase -i”
  1. Erik Cervin EdinDec 16, 2021
  2. Phillip WoodDec 16, 2021
  3. Erik Cervin EdinDec 16, 2021
  4. Philippe BlainJan 5, 2023
  5. Phillip WoodJan 6, 2023
  6. Philippe BlainJan 7, 2023
  7. Philippe BlainJan 7, 2023

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.