-
-
Save pauloperez/68607efba9533d096f9e584918f6b568 to your computer and use it in GitHub Desktop.
Merge one git repository into another repository as a sub-directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git clone repo_main | |
git clone repo_sub | |
cd repo_main | |
git remote add repo_sub ../repo_sub | |
git fetch repo_sub | |
git checkout -b repo_sub repo_sub/master | |
mkdir dir_repo_sub | |
for FILE in `ls -a --ignore dir_repo_sub --ignore .settings --ignore .project --ignore .git`; do git mv $FILE dir_repo_sub/$FILE ; done | |
git commit -m "Moves all repo_sub files into a single directory for merging back into repo_main" | |
git checkout master | |
git merge repo_sub | |
#fix tags | |
git tag -l | while read t; do n="dir_repo_sub/${t##*-}"; git tag $n $t; git tag -d $t; done | |
git push -u origin --tags | |
git branch -D repo_sub | |
git push -u origin --all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment