Skip to content

Instantly share code, notes, and snippets.

@jackocnr
Created March 3, 2014 01:54
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jackocnr/9317228 to your computer and use it in GitHub Desktop.
Save jackocnr/9317228 to your computer and use it in GitHub Desktop.
Git filesize history (shell script)
#!/bin/sh
#
# list the given file's filesize next to each commit
# usage: git-fs-history path/to/file
#
if [ $# -ne 1 ]; then
echo "Error: invalid number of arguments."
exit 1
fi
# for all commits on this file
for commit in $(git log --format=%H $1); do
# get raw filesize
fs_raw=$(git cat-file -s $commit:$1)
# convert to kilobytes
fs=$(echo "scale=1; $fs_raw/1024" | bc)k
# grab the commit msg
msg=$(git log -1 --format=%s $commit)
# print
echo $fs $msg
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment