首页 > 解决方案 > 无法提交我的更改并收到此错误

问题描述

提示:更新被拒绝,因为您当前分支的提示落后于提示:它的远程对应部分。在再次推送之前集成远程更改(例如提示:'git pull ...')。提示:有关详细信息,请参阅“git push --help”中的“关于快进的说明”。

标签: gitgithub

解决方案


如果您看到类似的消息REPOSITORY- 您的存储库名称和您的USERNAME并假设master是当前分支

$ git push origin master
To https://github.com/USERNAME/REPOSITORY.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/USERNAME/REPOSITORY.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.

然后,您可以执行以下操作:

有人在你最后一次 git fetch 和 git push 之间推送了新的提交。在这种情况下,您需要重复您的步骤和rebase master一次。

git fetch
git rebase master
git push origin master

推荐阅读