$ 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)
在pro的分支下运行上面的命令,把lib远程仓库添加到pro下,昵称是slibgit
$ git remote add slib git@192.168.1.1:lib.git
把代码拉到本地fetch
$ git fetch slib
把本地拉取的lib的仓库,切换到一个test分支,防止合并冲突很差解决spa
$ git checkout -b test slib/master
若是报下面的错误,说明你的slib对应的远程仓库没有对应的分支master,须要你先建立一个push上去,而后再运行上面的fetchcode
fatal: 'slib/master' is not a commit and a branch 'test' cannot be created from it
若是要把新分支内容合并到老分支,就切到老分支合并,若是是把老分支的内容合并到新分支,就直接合并。blog
切回到pro的一个分支rem
$ git checkout prodev
Checking out files: 100% (14522/14522), done. Switched to branch 'prodev'
把test merge过来,就能够了,可能会有错误it
$ git merge test
fatal: refusing to merge unrelated histories
添加命令,强制merge过来
解决冲突提交,就能够了ast
$ 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.