当前位置:   article > 正文

git push 出现 hint: Updates were rejected because the tip of your current branch is behind的解决办法

hint: updates were rejected because the tip of your current branch is behind

在 push 代码到远程仓库时出现版本冲突

错误示例:
在这里插入图片描述

$ git push origin develop
To https://github.com/***.git
 ! [rejected]        develop -> develop (non-fast-forward)
error: failed to push some refs to 'https://github.com/***.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

原因:

github上的版本和本地版本冲突的解决方法

解决办法一:

强制覆盖已有的分支(不推荐):

git push -u origin master -f 
  • 1

解决办法二:

先pull远程仓库,然后再push

git pull origin master --allow-unrelated-histories (该选项可以合并两个独立启动仓库的历史)
git push -u origin master
  • 1
  • 2
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/497685
推荐阅读
相关标签
  

闽ICP备14008679号