Skip to content

Searching Git History


# Removed semi-colons from the entire codebase
# Converted all JavaScript to TypeScript

Git Log / blame

  • View all commits that modified a file or a directory
  • git log --follow <path_to_dir_or_file>
    • don't use git log -p, that shows the entire diff
  • Get the SHA of the latest commit that changed a file
    • git --no-pager log -n 1 --pretty=format:%H -- <path_to_file_or_dir>

Git searching history

View how one file's changed across time

  • git log --follow -p -- file
  • Simpler version that doesn't follow: git log -p <filename>

Git search across branches

git grep "DialChart" `git show-ref --heads`

If that comes up empty

git grep "DialChart" $(git rev-list --all)

Git analytics

View the number of commits each person made

git shortlog -sen
git shortlog -sen COMMIT_HASH..HEAD
  • s: summary
  • n: sorted by number of commits
  • e: email

Get a commit from a specific time

git log --after="2022-03-01 00:00" --before="2022-03-01 23:59"

Last update: 2022-09-23