zoukankan      html  css  js  c++  java
  • 解决 Git 中 fatal: refusing to merge unrelated histories

    场景

    两个分支: feature/lytest。我在test分支上做了一些修改,现在需要合并到feature/ly分支。

    使用命令:

    Administrator@DESKTOP-H841QIF MINGW64 /g/ly_doc/glive (feature/ly)
    $ git merge --squash test
    fatal: refusing to merge unrelated histories
    

    这里的问题的关键在于:fatal: refusing to merge unrelated histories.

    你可能会在 git pull 或者 git push 中都有可能会遇到,这是因为两个分支没有取得关系。那么怎么解决呢?

    解决方案:

    在你操作命令后面加 --allow-unrelated-histories

    例如:

    git merge master --allow-unrelated-histories

    Administrator@DESKTOP-H841QIF MINGW64 /g/ly_doc/glive (feature/ly)
    $ git merge --squash test --allow-unrelated-histories
    CONFLICT (add/add): Merge conflict in ...
    Auto-merging ...
    Squash commit -- not updating HEAD
    Automatic merge failed; fix conflicts and then commit the result.
    
    

    如果你是 git pull 或者 git pushfatal: refusing to merge unrelated histories
    同理:
    git pull origin master --allow-unrelated-histories
    等等,就是这样完美的解决咯!

  • 相关阅读:
    android应用程序的混淆打包
    sql 语句的limit的用法
    Android SDK开发包国内下载地址
    在android应用程序中启动其他apk程序
    docker+k8s基础篇五
    docker+k8s基础篇四
    docker+k8s基础篇三
    docker+k8s基础篇二
    docker+k8s基础篇一
    LVS的基础使用
  • 原文地址:https://www.cnblogs.com/hnxbp/p/14888989.html
Copyright © 2011-2022 走看看