Created
September 6, 2016 15:21
-
-
Save clody69/8775641b69484e03aef62793c0ad3e84 to your computer and use it in GitHub Desktop.
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
# Instructions how to transfer several directories from one repo to another | |
# while preserving the history | |
git clone <git dest> dest | |
git clone <git src> src | |
# Prepare the source repo | |
cd src | |
git checkout <branch from where to copy the direcoties> | |
# For safety remove the original remote | |
git remote rm origin | |
# If only one directory | |
# git filter-branch --subdirectory-filter <directory to kepp> -- --all | |
# If multiple direcotries | |
git filter-branch -f --prune-empty --index-filter 'git rm --cached -r -q -- . ; git reset -q $GIT_COMMIT -- <dir a> <dir b>' -- --all | |
# Moving the directory to a different location while preserving history | |
~/git-mv-with-history.sh <old file>=<new file> <old file>=<new file> | |
# Merge the changes in the dest repo | |
cd ../dest | |
git remote add external ../src/ | |
git checkout <branch where to merge> | |
git pull external <branch from the src repo> --allow-unrelated-histories | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment