Skip to content

Instantly share code, notes, and snippets.

@155martinmoreno
Created December 4, 2019 09:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 155martinmoreno/e4ba0a87aa41bd97b518713320dae954 to your computer and use it in GitHub Desktop.
Save 155martinmoreno/e4ba0a87aa41bd97b518713320dae954 to your computer and use it in GitHub Desktop.
Shell to see lines count history of a file added to git.
#!/bin/sh
#
# list the given file's filesize next to each commit
# usage: git-fs-history path/to/file
#
if [ $# -ne 2 ]; then
echo "Error: invalid number of arguments."
exit 1
fi
echo "Lines,Date" > $2
# for all commits on this file
for commit in $(git log --format=%H $1); do
$(git checkout $commit)
commitDate=$(git show -s --format=%ci $commit)
wordCountAll=$(wc -l $1)
wordCount=($wordCountAll)
echo "${wordCount[0]},${commitDate}" >> $2
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment