Created
February 5, 2012 02:40
-
-
Save malloc47/1742150 to your computer and use it in GitHub Desktop.
Git Chopping and Cropping
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 | |
# remove a file or directory | |
set -e | |
EXPECTED_ARGS=1 | |
E_BADARGS=65 | |
if [ $# -lt $EXPECTED_ARGS ] | |
then | |
echo "Usage: `basename $0` [directory]" | |
exit $E_BADARGS | |
fi | |
git filter-branch -f --prune-empty --index-filter "git rm -rf --cached --ignore-unmatch $1" | |
git reflog expire --expire=now --all | |
git gc --aggressive --prune=now | |
git prune | |
git gc --aggressive | |
git repack | |
git repack -ad | |
git prune-packed |
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 | |
# remove all other directories | |
set -e | |
# do this first | |
# git clone --no-hardlinks /XYZ /ABC | |
EXPECTED_ARGS=1 | |
E_BADARGS=65 | |
if [ $# -lt $EXPECTED_ARGS ] | |
then | |
echo "Usage: `basename $0` [directory]" | |
exit $E_BADARGS | |
fi | |
git filter-branch --prune-empty --subdirectory-filter $1 HEAD -- --all | |
rm -rf .git/refs/original/ | |
git reflog expire --expire=now --all | |
git gc --aggressive --prune=now | |
git prune | |
git gc --aggressive | |
git repack | |
git repack -ad | |
git prune-packed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment