Skip to content

Instantly share code, notes, and snippets.

@muhrifqii
Created June 16, 2025 06:49
Show Gist options
  • Save muhrifqii/e798d5c8ace560021f90e6fa64a1712b to your computer and use it in GitHub Desktop.
Save muhrifqii/e798d5c8ace560021f90e6fa64a1712b to your computer and use it in GitHub Desktop.
Count local git contribution by commit count
GIT_PATH="~/gitlab"
cd $GIT_PATH && for repo in $(find . -type d -name ".git" | sed 's|/.git||'); do
cd "$repo" 2>/dev/null || continue
if [ -d .git ]; then
author=$(git config user.name 2>/dev/null || echo "unknown")
email=$(git config user.email 2>/dev/null || echo "unknown")
commit_count=0
if [ "$author" != "unknown" ]; then
commit_count=$(git log --oneline --author="$author" 2>/dev/null | wc -l)
fi
if [ "$email" != "unknown" ] && [ $commit_count -eq 0 ]; then
commit_count=$(git log --oneline --author="$email" 2>/dev/null | wc -l)
fi
if [ $commit_count -gt 0 ]; then
printf "%3d commits: %s\n" "$commit_count" "$repo"
fi
fi
cd ~/gitlab
done 2>/dev/null | sort -nr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment