I\'m working on a team with a few developers using git on BitBucket. We are all working on a dev
branch, not pushing to master
until a release.
git pull --rebase origin master
git push origin master
git push -f origin master
Warning git push -f origin master
It happens when we are trying to push to remote repository but has created a new file on remote which has not been pulled yet, let say Readme
. In that case as the error says
git rejects the update
as we have not taken updated remote in our local environment. So Take pull first from remote
git pull
It will update your local repository and add a new Readme
file.
Then Push updated changes to remote
git push origin master
git pull <remote> master:dev
will fetch the remote/master
branch and merge it into your local/dev
branch.
git pull <remote> dev
will fetch the remote/dev
branch, and merge it into your current branch.
I think you said the conflicting commit is on remote/dev
, so that is the branch you probably intended to fetch and merge.
In that case, you weren't actually merging the conflict into your local branch, which is sort of weird since you said you saw the incorrect code in your working copy. You might want to check what is going on in remote/master
.
I fixed it, I'm not exactly sure what I did. I tried simply pushing and pulling using:
git pull <remote> dev
instead of
git pull <remote> master:dev
Hope this helps out someone if they are having the same issue.
I had this error and it was because there was an update on the server but SourceTree was not showing any updates available (possibly because I was offline when it last checked). So I did a refresh in source tree and now it shows 2 items to push instead of 1 item.
So be sure to press refresh or pull if you get this error and then try again.