Skip to content

Instantly share code, notes, and snippets.

@EnchanterIO
Created December 1, 2017 12:02
Show Gist options
  • Save EnchanterIO/29976a17d5ad26ebcfbb05c4eacb5073 to your computer and use it in GitHub Desktop.
Save EnchanterIO/29976a17d5ad26ebcfbb05c4eacb5073 to your computer and use it in GitHub Desktop.
Merge unrelated git repositories into monolith and preserve history
Goal:
Move vendor repository to "src" directory of the project while keeping git files history.
Folder: buzz-platform
git checkout -b release-pop
Navigate outside the repository:
cd ../
Clone first vendor repo
git clone git@bitbucket.org:trivago/buzz-frontend-core-bundle.git frontend
Remove all files except the desired sub folder
cd frontend
git filter-branch --subdirectory-filter src/Buzz -- --all
Return to buzz-platform and create a origin pointing to new clean FrontendCoreBundle that is going to be merged
cd ../buzz-platform
git remote add frontend ../frontend
git fetch frontend
git merge --allow-unrelated-histories frontend/release
git mv FrontendCoreBundle src/Buzz/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment