From: Phillip Wood Date: Sun, 01 Sep 2024 15:26:27 GMT Subject: Re: `git rebase (--no-fork-point) --onto= [ []]` leaves HEAD detached and *HEAD not moved when is exactly `HEAD` Message-ID: <61a4fcc1-1dd8-48a4-a1d4-0201232c9b26@gmail.com> In-Reply-To: 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 " is designed to switch to a different branch before rebasing it. If you do not want to switch branches you should use "git rebase ". "" 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 HEAD" is behaving differently to "git checkout HEAD && git rebase ". 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