Created
June 23, 2019 18:41
-
-
Save JWhitleyWork/ab28f8abc1ec4b84baf9ac2abf06cfd4 to your computer and use it in GitHub Desktop.
Move Directory Between Git Repos with History
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
git clone source_repo && cd source_repo | |
git remote rm origin | |
git filter-branch -f --tree-filter \ | |
"find -maxdepth 1 -not -name . -not -name .git -not -name folder_to_move -print0 | xargs -0 rm -rf" \ | |
--tag-name-filter cat --prune-empty -- --all | |
cd .. | |
git clone target_repo && cd target_repo | |
git remote add source_repo ../source_repo | |
git pull source_repo master --allow-unrelated-histories | |
git push |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Replace
source_repo
,folder_to_move
, andtarget_repo
.