Skip to content

Instantly share code, notes, and snippets.

@luisfdeandrade
Created February 15, 2016 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luisfdeandrade/a8a99cb75ce4361ee003 to your computer and use it in GitHub Desktop.
Save luisfdeandrade/a8a99cb75ce4361ee003 to your computer and use it in GitHub Desktop.
Remove big files on GIT
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