zoukankan      html  css  js  c++  java
  • [git] Updates were rejected because the tip of your current branch is behind its remote counterpart.

    场景

    $ 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

  • 相关阅读:
    UVA11584 划分成回文串
    UVA1220Party at Hali-Bula(树的最大独立集 + 唯一性判断)
    BUAA1389愤怒的DZY(最大值最小化)
    九度1502 最大值最小化问题
    App(4.25)
    App(4.24)
    App(4.23)
    App(4.22)
    学习进度条(八)
    App(4.21)
  • 原文地址:https://www.cnblogs.com/tanglizi/p/11757236.html
Copyright © 2011-2022 走看看