Created
April 5, 2013 05:38
-
-
Save suderman/5316899 to your computer and use it in GitHub Desktop.
Remove files from git history
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
# FIND BIG FILES: | |
git rev-list --all --objects | \ | |
sed -n $(git rev-list --objects --all | \ | |
cut -f1 -d' ' | \ | |
git cat-file --batch-check | \ | |
grep blob | \ | |
sort -n -k 3 | \ | |
tail -n100 | \ | |
while read hash type size; do | |
echo -n "-e s/$hash/$size/p "; | |
done) | \ | |
sort -n -k1 | |
# REMOVE BIG FILES | |
git filter-branch -f --index-filter \ | |
'git rm --force --cached --ignore-unmatch UNWANTED-DIR/UNWANTED-FILE.PSD' \ | |
-- --all | |
rm -Rf .git/refs/original && \ | |
git reflog expire --expire=now --all && \ | |
git gc --aggressive && \ | |
git prune |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment