Skip to content

Instantly share code, notes, and snippets.

@icatalina
Forked from jackocnr/git-fs-history
Created September 26, 2018 14:12
Show Gist options
  • Save icatalina/772d1f55a0240f766e1d1b5742c608a6 to your computer and use it in GitHub Desktop.
Save icatalina/772d1f55a0240f766e1d1b5742c608a6 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