Last active
July 5, 2017 22:05
-
-
Save anavarre/7486059ea510e71d24c2 to your computer and use it in GitHub Desktop.
Merge 2 Git 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
#!/usr/bin/env bash | |
SOURCE_REPO="/local/path/to/source/repo" | |
REMOTE_NAME="github" | |
REMOTE_PATH="https://github.com/username/repo.git" | |
REMOTE_BRANCH="master" | |
# Prepare source repo. | |
cd ${SOURCE_REPO} | |
find . -not \( -name .git -prune \) -exec git rm -r {} \; | |
git commit -m "Remove source files" | |
# Merge remote repo files and history into source repo. | |
git remote add -f ${REMOTE_NAME} ${REMOTE_PATH} | |
git merge --no-edit ${REMOTE_NAME}/${REMOTE_BRANCH} | |
# Clean up | |
git remote remove ${REMOTE_NAME} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment