Created
October 15, 2019 22:12
-
-
Save cowboy-bebug/c82ae33c075441a42a236e160d4f6798 to your computer and use it in GitHub Desktop.
moving directories from one repo to another
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
# clone repos | |
mkdir move-repo && cd move-repo/ | |
git clone <repo-src> | |
git clone <repo-dst> | |
# prepare source | |
cd repo-src | |
#git checkout <branch-in-repo-src> # optional | |
#git remote rm origin # optional | |
git filter-branch --subdirectory-filter <directory-to-move> -- --all | |
mkdir new-dir/ | |
git mv -k * new-dir/ | |
git commit -m "collect data and history to move" | |
# prepare destination | |
cd ../repo-dst | |
git remote add repo-src ../repo-src/ | |
git fetch repo-src | |
git branch repo-src remotes/repo-src/master | |
git merge repo-src --allow-unrelated-histories | |
# either | |
git push origin master | |
# or | |
git checkout -b <branch-name> | |
git rebase origin/master | |
git push & pull request :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment