git push时提示rejected because the remote contains work that you do not have locally

首先,对于英语还可以的人来说,很容易就明白这个提示的意思是“因为您当前分支的最新提交落后于其对应的远程分支”。现在,你在本地库做了修改之后想推送到远程库,结果在git push的时候出了一个梗:

git push时提示rejected because the remote contains work that you do not have locally
! [rejected] master -> master (non-fast-forward)
error: 无法推送一些引用到 'git@github.com:mounui/Markdown.git'
提示:更新被拒绝,因为您当前分支的最新提交落后于其对应的远程分支。
提示:再次推送前,先与远程变更合并(如 'git pull ...')。详见
提示:'git push --help' 中的 'Note about fast-forwards' 小节。

解决办法:

先从远程库fetch(拉取)到更新再和本地库合并,之后就可以git push操作了。

在合并分支的时候如果有冲突不能快速合并需要解决冲突。

weinxin
我的微信
扫一扫加我微信
echo

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: