Created
May 3, 2015 07:08
-
-
Save skhatri/3d1fce9ab96ebb6f75c5 to your computer and use it in GitHub Desktop.
remove big 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
#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