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

Re: REBASE_HEAD still exists after success end rebase

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Jul 28, 2026, 13:21 UTC
Message-ID
<92a69a99-c56f-4ec5-968f-436bef64ee48@gmail.com>
In-Reply-To
<DKA3RP12A8LU.2VD89MQ7G2KLL@lfurio.us>
On 28/07/2026 10:39, Matt Hunter wrote:
Show 5 quoted lines
> On Tue Jul 28, 2026 at 4:26 AM EDT, Long 76 wrote:
>>
>> In other words REBASE_HEAD exists if ogirinal commit in new branch
>> modified and need call git push --force to send it to server. Please fix
>> it, thanks!

The need for "--force" when pushing is due to you having rebased the branch, it is unrelated to the existence of REBASE_HEAD (other than the fact that it exists indicates you have rebased). Rebasing rewrites the history which means that the remote cannot fast-forward when you push. Rather than using "--force" I'd recommend "--force-with-lease --force-if-includes" instead (see the "git push" man page for more details).

Show 11 quoted lines
> I ran into this not that long ago too, while working on a script.  It
> looked like this behavior depended on how the _last_ item in the rebase
> todo list was handled.  I found if the last action was a squash or edit
> (I don't think reword did this), then REBASE_HEAD was left behind.
> 
> Also, if rebase stops on a break command, then REBASE_HEAD will be
> missing, even though a rebase is still in-progress.
> 
> I made a very short-lived effort to look into why this "bug" was
> happening.  I say "bug" in quotes, because I'm not even sure if it is
> even problematic behavior.

I think leaving REBASE_HEAD behind after a rebase is a bug, albeit not a very serious one. Looking at the code we delete it before processing each command, but do not clean it up after the last command.

> I solved my need at the time (detecting a rebase in progress) by
> checking for the existence of either of the 'rebase-merge' or
> 'rebase-apply' directories in $GIT_DIR.

That's the best way to detect if a rebase is in progress - REBASE_HEAD only exists when there are conflicts, or the editor is opened for the user to reword a commit. It does not exist when the user is editing the todo list at the start of a rebase; when stopping for conflicts after a "merge parent" command without "-C"; when stopping for a break or failed exec command.

Thanks
Phillip
Previous: Matt HunterNext: Long 76
Message 3 of 6 in “REBASE_HEAD still exists after success end rebase”
  1. Long 76Jul 28, 2026
  2. Matt HunterJul 28, 2026
  3. Phillip WoodJul 28, 2026
  4. Long 76Jul 28, 2026
  5. Long 76Jul 28, 2026
  6. Long 76Jul 28, 2026

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.