美文网首页
Git push时遇到的错误

Git push时遇到的错误

作者: 3d8fa98de2ea | 来源:发表于2016-11-30 20:18 被阅读73次

错误信息:

error: failed to push some refs to 'git@10.10.3.166:/IOS_XDV_SB'

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.


原因分析:

因为提交的时候出现了冲突,例如:a和b两个人同时从远程clone了一个test仓库,并各自在本地对仓库中的1.txt文件进行了修改,接着,a先提交并push到远程仓库,成功。然后,b提交,push到远程仓库则会出现以上方法。


解决方法:

step1:    git pull 

情况1:如果a和b修改的是同一个文件,那么git不会为你自动合并该分支,需要你自动修改该文件出现的冲突部分,git会以用<<<<<<<,=======,>>>>>>>标记出不同分支的内容,我们修改保存后则可进行“step4”

情况2:如果a和b修改的不是同一个文件,那么执行git pull 后,则可成功执行“step4”

step4:    git push -u origin master -f

相关文章

网友评论

      本文标题:Git push时遇到的错误

      本文链接:https://www.haomeiwen.com/subject/ckitmttx.html