Last active
September 29, 2021 06:59
-
-
Save mkows/3bd1cd7ee25f8fa9f42aef629ef6fe82 to your computer and use it in GitHub Desktop.
git - extract a directory into a separate repository
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
# using: | |
# - git filter-branch OR | |
# - git filter-repo | |
# extract folder into a new repo | |
git clone [email protected]:__ORG__/__PROJECT__.git __LOCAL_ALIAS_DIR__ | |
cd __LOCAL_ALIAS_DIR__ | |
git co -b main | |
git filter-branch --prune-empty --subdirectory-filter __DIR_TO_EXTRACT__ main | |
# create __PROJECT_NEW__ repo in github and then: | |
git remote set-url origin [email protected]:__ORG__/__PROJECT_NEW__.git | |
git branch -M main | |
git push -u origin main | |
# or if you want to keep the original dir intact: | |
https://github.com/newren/git-filter-repo | |
git filter-repo --path __DIR_TO_EXTRACT__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment