Last active
March 3, 2017 12:31
-
-
Save Koriit/26260667080007c104a36187be11970d to your computer and use it in GitHub Desktop.
GIT: extracting a folder as new repo
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
# 1. cleanup working dir | |
git status | |
git reset --hard HEAD | |
git clean -nd | |
git clean -fd | |
# 2. remove origin refs | |
git remote rm origin | |
# 3. remove unnecessary tags and branches | |
## remove all tags and branches apart for your future master via GUI | |
## this will speed up the filtering and they need to be removed anyway | |
# 4. do the filtering | |
git filter-branch --subdirectory-filter <folder> -- --all | |
# 5. check if everything is ok | |
ls | |
git status | |
git log | |
# 6. remove lefovers if any | |
git clean -nf | |
git clean -df | |
# 7. remove backup refs | |
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d | |
# 8. run gc | |
git reflog expire --expire=now --all | |
git gc --prune=now | |
# 9. Remove entries for nonexistent branches | |
git config --local -e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment