首页 > 其他 > 详细

[git] Updates were rejected because the tip of your current branch is behind its remote counterpart.

时间:2019-10-29 11:29:47      阅读:142      评论:0      收藏:0      [点我收藏+]

场景

$ 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, 让网络图错综复杂, 十分难观察

  1. git push --force
    暴力更新代码, 这样会丢失远端的一些提交(或者代码)

  2. git pull ( fetch + merge )
    本地取远端修改, 然后合并

  3. git pull -- rebase ( fetch + rebase )
    本地取远端修改, 然后变基

merge 与 rebase 的区别

  1. merge 是新建一个commit, 在新的commit中, 在两个分支上各取最近祖先至今的修改, 合并, 移动head到最新分支上.

  2. rebase是不新建commit, 首先剪切本分支最近祖先至今的修改, 然后移动head到另一分支. 在另一个分支上, 粘贴刚才的修改, 移动head到最新修改上.

具体详见https://www.jianshu.com/p/c17472d704a0

[git] Updates were rejected because the tip of your current branch is behind its remote counterpart.

原文:https://www.cnblogs.com/tanglizi/p/11757236.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!