欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

git push异常整理 error: failed to push some refs to

程序员文章站 2022-07-11 08:29:33
...

目录

 

名称与 refs/heads/xxx 冲突

non-fast-forward(不能快速跟进)


名称与 refs/heads/xxx 冲突

$ git push origin HEAD:feature/xujingjian-20210318-xj-1.5.0-122187
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
To ssh://192.168.14.227:22/DefaultCollection/PSSCS/_git/app_peiwang_ionic_chat_2.0
 ! [remote rejected]   HEAD -> feature/xujingjian-20210318-xj-1.5.0-122187 (名称与 refs/heads/feature 冲突)
error: failed to push some refs to 'ssh://192.168.14.227:22/DefaultCollection/_git/app_2.0'

这个异常提示信息很少,但已经指出了异常是“名称与 refs/heads/feature 冲突”,feature是要push分支xujingjian-20210318-xj-1.5.0-122187所在的文件夹。为什么会提示它呢?为了搞明白去远程仓库检查了一下,原来没有feature这个文件夹。解决办法:创建feature文件夹,或把分支Push到其他文件下面。

non-fast-forward(不能快速跟进)

$ git push origin HEAD:xujingjian-20210318-xj-1.5.0-122187        
To ssh://192.168.14.227:22/DefaultCollection/_git/app_2.0
 ! [rejected]          HEAD -> xujingjian-20210318-xj-1.5.0-122187 (non-fast-forward)
error: failed to push some refs to 'ssh://192.168.14.227:22/DefaultCollection/PSSCS/_git/app_peiwang_ionic_chat_2.0'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and 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.

这个异常是non-fast-forward(不能快速跟进),就是说远程仓库已经有比本地仓库更新的commit。或许是你的同事先一步提交了代码。
解决办法:

  •  先git pull origin xujingjian-20210318-xj-1.5.0-122187
  • 如果有文件冲突先合并冲突,然后再git add 、git commit 、git push
相关标签: git