#!/usr/bin/env bash
# List all commits made by you in all repositories in the last month
set -euo pipefail
commits=()
for repopath in "$HOME/Dev/"*; do
if [[ ! -d "$repopath" ]]; then
continue
fi
if [[ ! -d "$repopath/.git" ]]; then
continue
fi
cd "$repopath"
name=$(git config --get user.name)
after=$(date -v-1m '+%Y-%m-%d')
lines=$(git log --all --author "$name" --format="%aI %cI %s" --after $after)
if [[ -z "$lines" ]]; then
continue
fi
while read -r line; do
author_timestamp=$(cut -d ' ' -f1 <<< "$line")
committer_timestamp=$(cut -d ' ' -f2 <<< "$line")
author_date=$(cut -d T -f 1 <<< "$author_timestamp")
committer_date=$(cut -d T -f 1 <<< "$committer_timestamp")
author_time=$(cut -c 12-16 <<< "$author_timestamp")
committer_time=$(cut -c 12-16 <<< "$author_timestamp")
title=$(cut -d ' ' -f3- <<< "$line")
commits+=("$author_date $author_time $title")
if [[ "$author_date" != "$committer_date" ]]; then
commits+=("$committer_date $committer_time $title")
fi
done <<< "$lines"
done
for line in "${commits[@]}"; do
echo "$line"
done | sort
- Shows
--all
commits from all branches, so if you amended a commit on a later date it will show up multiple times - Checks both author date and committer date, so you will se both when it was originally authored and when it was last committed, if on different dates
- Assumes that all your git repositories are in
$HOME/Dev/
, you could add multiple folders there - Assumes that all your commits have your
user.name
as authorgit config --get user.name
- To get a date 1 month ago I used
date -v-1m '+%Y-%m-%d'
. This is macOS specific. For linux you could trydate --date='-1 month' '+%Y-%m-%d'
. - If you are working on many different repos, you might want to print project folder name as well