git merge branches in different warehouses

1. lib incorporated 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. Add a remote warehouse to another warehouse

Run the above command in the pro branch, add lib remote repository to the next pro, nicknamed slib

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


3. Pull code to local warehouse

Local pulled the code

$ git fetch slib

 

4. Cut out the need to merge a branch of a remote repository newly added

The pull of local lib warehouse, switched to a test branch, merge conflicts prevent bad solution

$ git checkout -b test slib/master


If the report the following error to show that you slib corresponding remote repository no corresponding branch master, you need to create a push up, and then run the above fetch

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

 

 5. Merge

If you want to merge the contents of the new branch old branch, cut it to merge the old branch, if the content is to merge the old branch to the new branch, direct merger.

Cut back a branch of the pro

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

 

The test merge over it, there may be errors

$ git merge test
fatal: refusing to merge unrelated histories


Add a command to force merge over the
settlement of the conflict submitted, it

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

 

Guess you like

Origin www.cnblogs.com/studywithallofyou/p/11766569.html