Re: REBASE_HEAD still exists after success end rebase
- From
- Phillip 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