zoukankan      html  css  js  c++  java
  • git合并不同仓库下的分支

    1.把lib合并到pro

    $ git remote -v
    origin  git@192.168.1.1:lib.git (fetch)
    origin  git@192.168.1.1:lib.git (push)
    $ git remote -v
    origin  git@192.168.1.1:pro.git (fetch)
    origin  git@192.168.1.1:pro.git (push)

    2.把一个远程仓库添加到另一个仓库中

    在pro的分支下运行上面的命令,把lib远程仓库添加到pro下,昵称是slib

    $ git remote add slib git@192.168.1.1:lib.git


    3.拉取仓库代码到本地

    把代码拉到本地

    $ git fetch slib

    4.切出一个需要合并的新添加的远程仓库的分支

    把本地拉取的lib的仓库,切换到一个test分支,防止合并冲突不好解决

    $ git checkout -b test slib/master


    如果报下面的错误,说明你的slib对应的远程仓库没有对应的分支master,需要你先创建一个push上去,然后再运行上面的fetch

    fatal: 'slib/master' is not a commit and a branch 'test' cannot be created from it

     5.合并

    如果要把新分支内容合并到老分支,就切到老分支合并,如果是把老分支的内容合并到新分支,就直接合并。

    切回到pro的一个分支

    $ git checkout prodev
    Checking out files: 100% (14522/14522), done.
    Switched to branch 'prodev'

    把test merge过来,就可以了,可能会有错误

    $ git merge test
    fatal: refusing to merge unrelated histories


    添加命令,强制merge过来
    解决冲突提交,就可以了

    $ git merge test --allow-unrelated-histories
    Auto-merging .gitignore
    CONFLICT (add/add): Merge conflict in .gitignore
    Automatic merge failed; fix conflicts and then commit the result.
  • 相关阅读:
    OD: Kernel Vulnerabilities
    newInstance()和new的区别
    原型模式
    工厂模式
    代理模式
    策略模式
    简单工厂模式
    C#操作符的重载
    旅行之舌尖上的中国
    模式和原则[转载]
  • 原文地址:https://www.cnblogs.com/studywithallofyou/p/11766569.html
Copyright © 2011-2022 走看看