
Let's say the following is being returned.
To ssh://git@example.com:7999/path/to/example.git
! [rejected] HEAD -> master (non-fast-forward)
error: failed to push some refs to 'ssh://git@example.com:7999/path/to/example.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
In this scenario, I start by using the git branch --all command to see what branch I am on. In this example, I am on the feature/foo branch.
~]# git branch --all
feature/bar
* feature/foo
master
remotes/origin/HEAD -> origin/master
remotes/origin/feature/bar
remotes/origin/feature/foo
remotes/origin/master
It may be the case the my clone of the feature/foo branch is behind the feature/foo branch in the origin thus this issue can often be resolved by using the git pull command to pull down any new commits from the origin to my clone of the repo.
git pull origin feature/foo
Try git pull and see if "your local changes would be overwritten by merge". If so, check out my article on resolving your local changes would be overwritten by merge.
If "your local changes would be overwritten by checkout" is being returned, check out my article on resolving your local changes would be overwritten by checkout.
Did you find this article helpful?
If so, consider buying me a coffee over at