Add a remote repo
1 | git remote add -f repo-name git@github.com:repo.git |
Merge the repo into the local git project
1 | git merge -s ours --no-commit --allow-unrelated-histories repo-name/master |
Create a new directory named pro-name and copy the git history of remote repo project into it.
1 | git read-tree --prefix=pro-name/ -u spoon-knife/master |
Commit the changes to keep them safe
1 | git commit -m "subtree merged" |
Synchronizing with remote repo
1 | git pull -s subtree repo-name branchname |
However, I met overlaps with
problem. And need add -Xsubtree
to specify the directory where the sub-project should pull.
1 | git pull -s subtree -Xsubtree=pro-name repo-name branchname |