add
Use git-subtree
to import a Git repository into another repository:
$ git subtree add --prefix <prefix> <repository> <revision>
For instance, to import the repository [email protected]:remarkablemark/example.git
into the current repository’s subdirectory ./example/
:
$ git subtree add -P example [email protected]:remarkablemark/example.git master
You can check the commit output with git show
:
$ git show
Add 'examaple/' from commit 'e28d0c5ef4c8e69eacea877af979923926f0c5e9'
git-subtree-dir: example
git-subtree-mainline: 32120bbb677c6786d7219de6c8c83b4bb8fc9ba0
git-subtree-split: e28d0c5ef4c8e69eacea877af979923926f0c5e9
pull
To update to the latest revision on the subtree repository:
$ git subtree pull --prefix <prefix> <repository> <revision>
In our example, we would do the following:
$ git subtree pull -P example [email protected]:remarkablemark/example.git master