Thank you for filling out a Git bug report! Please answer the following questions to help us understand your issue. What did you do before the bug happened? (Steps to reproduce your issue) cd '/'; cd '/'; rm --force --recursive -- './test_git'; mkdir "$_"; cd "$_"; mkdir --parents -- './server' './client'; git -C './server' init --bare './repo.git' echo '1' >'./file'; git --git-dir='./server/repo.git' --work-tree='.' add './file'; git --git-dir='./server/repo.git' --work-tree='.' commit -m "$((++number))" echo '2' >'./file'; git --git-dir='./server/repo.git' --work-tree='.' add './file'; git --git-dir='./server/repo.git' --work-tree='.' commit -m "$((++number))" git -C './server/repo.git' log --graph --all --patch git -C './client' clone '../server/repo.git' './repo' branch_default_path="$(git -C './client/repo' symbolic-ref HEAD)" branch_default_name="${branch_default_path#'refs/heads/'}" echo '3' >'./client/repo/file'; git -C './client/repo' add './file'; git -C './client/repo' commit -m "$((++number))" git -C './client/repo' log --graph --all --patch git -C './server/repo.git' reset --soft HEAD~1 echo '4' >'./file'; git --git-dir='./server/repo.git' --work-tree='.' add './file'; git --git-dir='./server/repo.git' --work-tree='.' commit -m "$((++number))" git -C './server/repo.git' log --graph --all --patch git -C './client/repo' fetch --all git -C './client/repo' log --graph --all --patch 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 -C './client/repo' log --graph --all --patch echo '5' >'./client/repo/file'; git -C './client/repo' add './file'; git -C './client/repo' -c 'core.editor=:' rebase --continue git -C './client/repo' log --graph --all --patch git -C './client/repo' checkout -B "$branch_default_name" git -C './client/repo' log --graph --all --patch What did you expect to happen? (Expected behavior) HEAD points to GIT_DEFAULT_BRANCH and GIT_DEFAULT_BRANCH points to tip of origin's GIT_DEFAULT_BRANCH when rebase completes. What happened instead? (Actual behavior) HEAD is detached and *HEAD is not moved when rebase completes, so `git checkout -B` is needed. What's different between what you expected and what actually happened? Anything else you want to add: Replacing `HEAD` with branch name (`"$(git -C './client/repo' branch --show-current)"`) works around the problem. cd '/'; cd '/'; rm --force --recursive -- './test_git'; mkdir "$_"; cd "$_"; mkdir --parents -- './server' './client'; git -C './server' init --bare './repo.git' echo '1' >'./file'; git --git-dir='./server/repo.git' --work-tree='.' add './file'; git --git-dir='./server/repo.git' --work-tree='.' commit -m "$((++number))" echo '2' >'./file'; git --git-dir='./server/repo.git' --work-tree='.' add './file'; git --git-dir='./server/repo.git' --work-tree='.' commit -m "$((++number))" git -C './server/repo.git' log --graph --all --patch git -C './client' clone '../server/repo.git' './repo' echo '3' >'./client/repo/file'; git -C './client/repo' add './file'; git -C './client/repo' commit -m "$((++number))" git -C './client/repo' log --graph --all --patch git -C './server/repo.git' reset --soft HEAD~1 echo '4' >'./file'; git --git-dir='./server/repo.git' --work-tree='.' add './file'; git --git-dir='./server/repo.git' --work-tree='.' commit -m "$((++number))" git -C './server/repo.git' log --graph --all --patch git -C './client/repo' fetch --all git -C './client/repo' log --graph --all --patch git -C './client/repo' -c 'core.editor=cat' rebase --onto=HEAD@{upstream} --interactive "$(git -C './client/repo' merge-base --fork-point HEAD@{upstream} HEAD)" "$(git -C './client/repo' branch --show-current)" git -C './client/repo' log --graph --all --patch echo '5' >'./client/repo/file'; git -C './client/repo' add './file'; git -C './client/repo' -c 'core.editor=:' rebase --continue git -C './client/repo' log --graph --all --patch Please review the rest of the bug report below. You can delete any lines you don't wish to share. [System Info] git version: git version 2.46.0.windows.1 cpu: x86_64 built from commit: 2e6a859ffc0471f60f79c1256f766042b0d5d17d sizeof-long: 4 sizeof-size_t: 8 shell-path: D:/git-sdk-64-build-installers/usr/bin/sh feature: fsmonitor--daemon libcurl: 8.9.0 OpenSSL: OpenSSL 3.2.2 4 Jun 2024 zlib: 1.3.1 uname: Windows 10.0 22631 compiler info: gnuc: 14.1 libc info: no libc information available $SHELL (typically, interactive shell): C:\Program Files\Git\usr\bin\bash.exe [Enabled Hooks] not run from a git repository - no hooks to show