Created
February 21, 2013 11:42
-
-
Save mongris/5004194 to your computer and use it in GitHub Desktop.
Detach subdirectory into separate Git repository
from: http://stackoverflow.com/a/9510944
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
#!/bin/bash | |
# | |
# git-subdir.sh | |
# | |
git clone --no-hardlinks $1 $2 | |
cd $2 | |
git filter-branch --subdirectory-filter $2 --prune-empty --tag-name-filter cat HEAD -- --all | |
git reset --hard | |
git remote rm origin | |
refbak=$(git for-each-ref --format="%(refname)" refs/original/) | |
if [ -n "$refbak" ];then | |
echo -n $refbak | xargs -n 1 git update-ref -d | |
fi | |
git reflog expire --expire=now --all | |
git repack -ad | |
git gc --aggressive --prune=now |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment