Re: `git rebase (--no-fork-point) --onto=<newbase> [<upstream> [<branch>]]` leaves HEAD detached and *HEAD not moved when <branch> is exactly `HEAD`
- From
- Phillip Wood <phillip.wood123@gmail.com>
- Date
- Sep 1, 2024, 15:26 UTC
- Message-ID
- <61a4fcc1-1dd8-48a4-a1d4-0201232c9b26@gmail.com>
- In-Reply-To
- <CANrWfmSY1F4UB2QSjN8XKY7Kwx6FL8SOrz_OadZ4u8XYDpZfBg@mail.gmail.com>
On 01/09/2024 12:02, Han Jiang wrote:
> What did you do before the bug happened? (Steps to reproduce your issue)
> git -C './client/repo' -c 'core.editor=cat' rebase
> --onto=HEAD@{upstream} --interactive "$(git -C './client/repo'
> merge-base --fork-point HEAD@{upstream} HEAD)" HEAD"git rebase <upstream> <branch>" is designed to switch to a different branch before rebasing it. If you do not want to switch branches you should use "git rebase <upstream>". "<branch>" is expected to be a branch name, not a symbolic ref to the branch like "HEAD".
> Replacing `HEAD` with branch name (`"$(git -C './client/repo' branch > --show-current)"`) works around the problem.
This is working as expected.
"git checkout HEAD" is a no-op so "git rebase <upstream> HEAD" is behaving differently to "git checkout HEAD && git rebase <upstream>". We could look at changing that but it would be a breaking change for anyone relying on the current behavior to detach HEAD before rebasing.
Best Wishes
Phillip