Skip to content

Instantly share code, notes, and snippets.

@zaki
Created October 31, 2014 10:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zaki/20a80a3992d576f55754 to your computer and use it in GitHub Desktop.
Save zaki/20a80a3992d576f55754 to your computer and use it in GitHub Desktop.
Merge two repositories
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