Created
May 9, 2018 07:27
-
-
Save teohm/8969ba8ebc74085ef1840d9c936b0ccf to your computer and use it in GitHub Desktop.
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
# based on the following: | |
# http://saintgimp.org/2013/01/22/merging-two-git-repositories-into-one-repository-without-losing-file-history/ | |
# http://blog.caplin.com/2013/09/18/merging-two-git-repositories/ | |
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 | |
# '*' will cause git mv to fail because it cannot move dir_repo_sub into itself | |
git mv <list all files> | |
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 | |
# commit and push, and you're finished |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
in case of this error
fatal: refusing to merge unrelated histories
, check the below link:https://stackoverflow.com/questions/37937984/git-refusing-to-merge-unrelated-histories-on-rebase