# Merging Two Repos With Unrelated Histories
Subtree copying is one way of nesting repository inside another repository. The other way are [[Git Submodules]].
1. Import project b into project a (remote + fetch or similar)
2. Execute the following commands
``` shell
git merge -s ours --no-commit projectb/master --allow-unrelated-histories
git read-tree --prefix=vendor/projectb/ -u projectb/master
```
`projectb` above is the name of the remote used in step 1. `projectb/master` in `read-tree` can be any branch (including `FETCH_HEAD`).
Histories of both projects will be preserved.
## Sources
- [Subtree merging and you](https://nuclearsquid.com/writings/subtree-merging-and-you/)