How to merge two Git repositories
There is a great article about this. A use case:
ProjectFoo
AnddroidLibrary
Foo
Foo
Android Library and Foo > Foo have their own repositories.
The steps:
- Create directory GIT Merge\Foo under directory ProjectFoo.
- Create foo.txt under GIT merge
- PS: cd "E:\Users\h\Documents\Hong\ProjectFoo\GIT Merge\Foo"
- PS: dir > foo.txt
- PS: git add .
- PS: git commit -m “Initial dummy commit”
- PS: git remote add -f AndroidLibrary http://phenomvii/Bonobo.Git.Server/androidLibrary.git
- PS: git merge AndroidLibrary/master --allow-unrelated-histories
- PS: git rm .\foo.txt
- PS: git commit -m “Clean up initial file”
- PS: mkdir AndroidLibrary
- PS: cd "E:\Users\h\Documents\Hong\RandD\AndroidstudioProjects\Onvifer\androidlibrary"
- PS: git init
- git remote add -f AndroidLibrary http://phenomvii/Bonobo.Git.Server/androidLibrary.git
- PS: dir > foo.txt
- PS: git add .
- PS: git commit -m “Initial dummy commit”
- PS: git remote add -f AndroidLibrary http://phenomvii/Bonobo.Git.Server/androidLibrary.git
- PS: git merge AndroidLibrary/master
- PS: git merge AndroidLibrary/master --allow-unrelated-histories
- PS: git rm .\foo.txt
- Resolve merge conflict with PS: git mergetool after backing up merged files
- PS: git commit -m “merged”
- PS: git pull AndroidLibrary
- PS: rm -rf AndroidLibrary/.git remove the git repository created for the sole purpose of merging