Skip to content

Instantly share code, notes, and snippets.

@cgrs
Last active November 11, 2019 14:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cgrs/4892c2a28711f97da62fff69b2cec483 to your computer and use it in GitHub Desktop.
Save cgrs/4892c2a28711f97da62fff69b2cec483 to your computer and use it in GitHub Desktop.
Create a commit report in a list of git repositories

Usage

./git-report [git-repo-directory/ies] [since] [until]

Example

$ ./git-report sw-task-scheduler "2018/04/01" "2018/04/30"
Commits from 2018/06/01 to 2018/06/30
> sw-task-scheduler (on firebase branch):
  2018-06-11 [HEAD -> firebase - beab5f1] fix: restrict access to authenticated users only
  2018-06-06 [origin/firebase - e87888c] refactor: start using firebase
  2018-06-04 [origin/webpush, webpush - f90d777] feature: background Web Push Notifications API

Known issues

It only list commits from current HEAD, it does not show commits from other branches.

#!/usr/bin/env bash
WORKDIR=${1:-`pwd`}
SINCE=${2:-"1970/01/01"}
UNTIL=${3:-`date +%Y/%m/%d`}
echo "Commits from ${SINCE} to ${UNTIL}"
for dir in ${WORKDIR}*/; do
pushd $dir &> /dev/null
if [ -d .git ]; then
repo=$(basename ${dir})
echo "> ${repo} (on $(git branch | sed -n '/\* /s///p') branch):"
git --no-pager log \
--all \ # log all commits in history
--author="$(git config --global user.email)" \
--pretty=" %cd [%D - %h] %s" --no-color \
--date=short \
--since=$SINCE \
--until=$UNTIL
fi
popd &> /dev/null
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment