Created
September 28, 2012 23:27
-
-
Save nuclearsandwich/3802586 to your computer and use it in GitHub Desktop.
Find large files in your git repos
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
#!/bin/bash | |
# big_files.bash | |
## Iterate over commit history and print big files and folders. | |
## usage: big_files.bash | |
# git-rev-list - print each revision in the HEAD reference | |
git rev-list --reverse HEAD \ | |
| while read rev; do | |
echo "Current revision: $rev" | |
# git-checkout - Check out a revision locally. Send the warning to /dev/null | |
git checkout $rev 2>/dev/null | |
# du - Print the disk usage of a local project | |
# sort - sort each line descending numerically | |
# head - take the 10 largest files/folders | |
du -I ".git" \ | |
| sort -rn \ | |
| head -${nfiles:-"20"} | |
# Spacer | |
printf "######################\n\n" | |
done | |
# ZOMG We're done! | |
git checkout master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment