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.
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)