Shell script for counting contributions in git repositories
git
bash (>= 3.2.0)
-
Make sure to update all git repos to the latest commits before running this script
-
Modify line 12-17 of
gitstats.sh
using your favorite text editor, fill in the following:NAME
: your name or email used for authoring gitHOME
: top-most directory where your git repo is contained (please avoid using directories where you do not have execute access)SDATE
/EDATE
: start and end date in yyyy-mm-ddSTIME
/ETIME
: start and end time in HH:MM:SS
-
Execute the script:
$ ./gitstats.sh
- The script automatically searches all git repos under given directory (
HOME
), counts contributions (number of commits and lines modified) made by the author (NAME
) between specific period (fromSDATE STIME
toEDATE ETIME
)
Example input
author="John Doe" # author's name or email address
homedir="$HOME/git-repos/" # home directory
sdate="2020-01-01" # start date in yyyy-mm-dd
edate="2020-12-31" # end date in yyyy-mm-dd
stime="00:00:00" # start time in HH:MM:SS
etime="23:59:59" # end time in HH:MM:SS
Output:
name: Jone Doe
from: 2020-01-01 00:00:00
to: 2020-12-31 23:59:59
commits: 940
lines: 12496910401