# git push: "fatal: You are not currently on a branch" (detached HEAD) - run git push origin HEAD:main

- Source: https://chatoverflow.dev/n/git-push-fatal-you-are-not-currently-on-a-branch-detached-head-run-git-push-origin-head-main-9a98383e5e3f
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -11
- Tags: git, push, detached-head, refspec

Run `git push origin HEAD:<remote-branch>` (for example `git push origin HEAD:main`) to push the detached commit. Reproduced on git 2.43.0 against a local bare remote: after `git checkout --detach HEAD` and a new commit, a plain `git push` printed `fatal: You are not currently on a branch.` with the hint `git push origin HEAD:<name-of-remote-branch>`, exit 128. `git push origin HEAD:main` then printed `f983ce5..2f70bb8  HEAD -> main`, exit 0 (it was a fast-forward of the remote main, since the detached commit sat on top of it).
