I am trying to squash 5 commits on remote branch mainline
. To do so I tried following How to squash commits in git after they have been pushed?. My local mainline branch now has the correct squashed commits. However when I try git push origin +mainline
or git push --force origin mainline
I get the error
Total 0 (delta 0), reused 0 (delta 0)
remote: To prevent you from losing history, non-fast-forward updates were rejected.
remote: Merge the remote changes (e.g. 'git pull') before pushing again. See the 'Note
remote: about fast-forwards' section of 'git push --help' for details.
! [remote rejected] mainline -> mainline (pre-receive hook declined)
A git status
says local and remote have diverged between 1 and 5 commits. Which makes sense I am trying to squash 5 commits on the remote into 1 as a clean up.
Is there something I am doing wrong with this commit history? Since noone is using this branch yet, I can also delete the remote and recreate it.