Created
October 31, 2014 10:51
-
-
Save zaki/20a80a3992d576f55754 to your computer and use it in GitHub Desktop.
Merge two repositories
This file contains 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
mkdir repo_merge | |
cd repo_merge | |
git clone zaki/test_server | |
git clone zaki/test_client | |
## PREPROCESS SERVER | |
cd test_server | |
git remote rm origin # precaution | |
# move all files with history to server/ | |
git filter-branch --index-filter 'git ls-files -s | sed "s- \"*-&server/-" | GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index --index-info && mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"' HEAD | |
## PREPROCESS CLIENT | |
cd test_client | |
git remote rm origin # precaution | |
# move all files with history to client/ | |
git filter-branch --index-filter 'git ls-files -s | sed "s- \"*-&client/-" | GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index --index-info && mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"' HEAD | |
## MERGE SERVER INTO CLIENT | |
git remote add -f server ../test_server | |
git merge server/master | |
git remote rm server | |
## RESULTS IN | |
## client/ | |
## L---client contents | |
## server/ | |
## L---server contents |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment