blueChair blueChair - 9 days ago 8
Git Question

Not able to push after resolving merge conflicts

My friend and I had made changes to same branch, he pushed onto it and after sometime I tried to do the same but I got. but I got error saying :

error: failed to push some refs to '<repo_name>'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.


So I did a pull from the remote branch and resolved merge conflicts.

But after that when I tried to push to the remote having included changes from both me and my friend it said :

Everything up-to-date


but my changes are still not reflected in the remote repo. What am I missing here ?

Answer

Your local branch is behind from remote branch. So, at first pull the changes of remote then push your changes.

$ git fetch
$ git pull origin <branch-name>
$ git push origin HEAD

Or, you can use rebase. This takes all server changes and put your commit/changes at the top in git log.

$ git pull --rebase
$ git push origin HEAD              # push your local commit(s)