我和我的 friend 对同一个分支进行了更改,他 push 了它,过了一段时间我尝试做同样的事情但我成功了。但我收到错误消息:
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.
所以我从远程分支 pull 并解决了 merge 冲突。
但在那之后,当我尝试推送到包含我和我 friend 的更改的远程时,它说:
Everything up-to-date
但我的更改仍然没有反射(reflect)在远程仓库中。我在这里错过了什么?
最佳答案
您的本地分支
落后于远程分支
。因此,首先 pull 远程的更改,然后推送您的更改。
$ git fetch
$ git pull origin <branch-name>
$ git push origin HEAD
或者,您可以使用rebase
。这会获取所有远程提交,然后将您的提交放在 git log 中的顶部
。
$ git pull --rebase
$ git push origin HEAD # push your local commit(s)
关于git - 解决 merge 冲突后无法推送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40868950/