I made three commits to a branch and pushed each of them to remote. I then needed to squash the commits, so I used:
git reset --soft HEAD~3 && git commit
git push --force
At the second line, I got a fatal error:
The current branch [BRANCH-NAME] has no upstream branch.
To push the current branch and set the remote as upstream.
I tried its suggested command with git push --set-upstream origin [BRANCH-NAME]
, but am being told that the tip of the current branch is behind its remote counterpart. Looking back, it makes sense, as I'm currently on index 1 of my local branch while the head is at index 3 on the remote.
What I want to do now is basically to have the squashed version of the branch (which I have locally) replace the non-squashed version that is in the remote. What's the right approach here?
I've looked at this and a couple of others but they haven't helped.