git - 解决 merge 冲突后无法推送

标签 git github

我和我的 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/

相关文章:

git - 如何截断或减少 GitHub 上的 git repo

github - 错误 : blob is too big - downloading a single zip file from github repo

用于 cd 到 git root 的 shell 命令的 git 别名未按预期工作

node.js - 如何从本地文件夹更新 npm 包

git - 在 master 分支上意外执行 "Git push origin master"

git - 将损坏的松散对象修复为 git 中的提交

java - import 语句中的点变成红色 - github 比较

git - 远程 : Invalid username or password

bash - 获取 git 命令列表

git - intellij 可以向我显示最近 x 次提交的更改,就好像它们是刚刚提交的一样吗?