Skip to content

Instantly share code, notes, and snippets.

@kashishgrover
Last active January 27, 2023 08:06
Show Gist options
  • Save kashishgrover/5696a5aa50fd18cc6216ffe12500f564 to your computer and use it in GitHub Desktop.
Save kashishgrover/5696a5aa50fd18cc6216ffe12500f564 to your computer and use it in GitHub Desktop.
Merge a remote repo into a subdirectory of another repo
git remote add <remote-name> <remote-url>

git fetch <remote-name> --tags

git subtree add --prefix <subdirectory> <remote-name> <sha>
@kashishgrover
Copy link
Author

To merge commits from the other repo later on, do this:

git fetch <remote-name> --tags
git merge <remote-name>/<branch-name> --allow-unrelated-histories

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment