Created
July 25, 2013 10:21
-
-
Save holms/6078511 to your computer and use it in GitHub Desktop.
Create repository from git subdirectory
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
git clone /XYZ /ABC # To clone your local repository | |
cd ABC | |
git remote rm origin | |
# only rewrite the HEAD branch and ignore tags and other branches | |
git filter-branch --tag-name-filter cat --prune-empty --subdirectory-filter subdirectory_to_repo HEAD | |
# then delete the backup reflogs so the space can be truly reclaimed (although now the operation is destructive) | |
git reset --hard | |
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d | |
git reflog expire --expire=now --all | |
git gc --aggressive --prune=now |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment