Find the largest unstaged files in Git

I was recently adding a bunch of files to a new Git repo, but I couldn't be sure if I was about to commit a 100MB file. The following bash command should print out a sorted list of unstaged files and their size, so you can check if you are about to do the same.

git status -u --porcelain | sed 's/^...//;s/^"//;s/"$//' | while read path; do du -bs "$path"; done | sort -n

Show Comments