Skip to content

Instantly share code, notes, and snippets.

@skhatri
Created May 3, 2015 07:08
Show Gist options
  • Save skhatri/3d1fce9ab96ebb6f75c5 to your computer and use it in GitHub Desktop.
Save skhatri/3d1fce9ab96ebb6f75c5 to your computer and use it in GitHub Desktop.
remove big files from git history
#list top 10 big files
index_file=$(ls .git/objects/pack/pack-*.idx)
for x in $(git verify-pack -v $index_file| sort -k 3 -n | tail -10); do
git rev-list --objects --all | grep $x
done
#remove all war
git filter-branch -f --index-filter 'git rm -rf --cached --ignore-unmatch *.war' -- --all
#pack all
git pack-refs --all --prune
#expire old reflogs
git reflog expire --expire-unreachable=now --all
#pack unpacked files
git repack -A -d
#git clean up
git gc --aggressive --prune=now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment