首页 / GIT / [git] Updates were rejected because the tip of your current branch is behind its remote counterpart.
[git] Updates were rejected because the tip of your current branch is behind its remote counterpart.
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了[git] Updates were rejected because the tip of your current branch is behind its remote counterpart.,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含970字,纯文字阅读大概需要2分钟。
内容图文
![[git] Updates were rejected because the tip of your current branch is behind its remote counterpart.](/upload/InfoBanner/zyjiaocheng/1152/d6193ad7bc70418f918a8b87cfdbf8e2.jpg)
场景
$ git push
To https://github.com/XXX/XXX
! [rejected] dev -> dev (non-fast-forward)
error: failed to push some refs to 'https://github.com/XXX/XXX'
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.
原因
远端冲突
解决方案
推荐方案3
因为merge会新建commit, 让网络图错综复杂, 十分难观察
-
git push --force
暴力更新代码, 这样会丢失远端的一些提交(或者代码) -
git pull ( fetch + merge )
本地取远端修改, 然后合并 -
git pull -- rebase ( fetch + rebase )
本地取远端修改, 然后变基
merge 与 rebase 的区别
-
merge 是新建一个commit, 在新的commit中, 在两个分支上各取最近祖先至今的修改, 合并, 移动head到最新分支上.
-
rebase是不新建commit, 首先剪切本分支最近祖先至今的修改, 然后移动head到另一分支. 在另一个分支上, 粘贴刚才的修改, 移动head到最新修改上.
具体详见https://www.jianshu.com/p/c17472d704a0
原文:https://www.cnblogs.com/tanglizi/p/11757236.html
内容总结
以上是互联网集市为您收集整理的[git] Updates were rejected because the tip of your current branch is behind its remote counterpart.全部内容,希望文章能够帮你解决[git] Updates were rejected because the tip of your current branch is behind its remote counterpart.所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。