Skip to content

Instantly share code, notes, and snippets.

@mcpar-land
Created April 8, 2026 16:43
Show Gist options
  • Select an option

  • Save mcpar-land/71a3dbc9ef50aa1f5c6420dc9d79990c to your computer and use it in GitHub Desktop.

Select an option

Save mcpar-land/71a3dbc9ef50aa1f5c6420dc9d79990c to your computer and use it in GitHub Desktop.
Git repository analysis commands
# https://piechowski.io/post/git-commands-before-reading-code/
cd ${1?.}
echo "# Most changed files, last year"
echo '```'
git log --format=format: --name-only --since="1 year ago" \
| sort \
| uniq -c \
| sort -nr \
| head -20
echo '```'
echo
echo "# Contributors by commit count"
echo '```'
git shortlog -sn --no-merges
echo '```'
echo
echo "# Commits with bug keywords"
echo '```'
git log -i -E --grep="fix|bug|broken" --name-only --format='' | sort | uniq -c | sort -nr | head -20
echo '```'
echo
echo "# Commits by month"
echo '```'
git log --format='%ad' --date=format:'%Y-%m' | sort | uniq -c
echo '```'
echo
echo "# Revert and hotfix frequency"
echo '```'
git log --oneline --format='%ad %s' --date=format:'%Y-%m-%d' --since="1 year ago" | grep -iE 'revert|hotfix|emergency|rollback'
echo '```'
@mcpar-land
Copy link
Copy Markdown
Author

Inspired by this post, I assembled all the commands in that post into a single script that outputs a markdown-compatible report. Pipe it into a markdown file or a markdown pretty-printer like glow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment