Created
March 3, 2014 01:54
-
-
Save jackocnr/9317228 to your computer and use it in GitHub Desktop.
Git filesize history (shell script)
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
#!/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) | |
echo $fs $msg | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment