$ 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.