Created
February 15, 2016 16:01
-
-
Save luisfdeandrade/a8a99cb75ce4361ee003 to your computer and use it in GitHub Desktop.
Remove big files on GIT
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 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 -n40 | \ | |
while read hash type size; do | |
echo -n "-e s/$hash/$size/p "; | |
done) | \ | |
sort -n -k1 | |
git filter-branch -f --index-filter \ | |
'git rm --force --cached --ignore-unmatch big-file.zip' \ | |
-- --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