Find Git commits by email address

Often in Git you’ll want to find a list of commits from a given author or organisation. Fortunately this is a simple enough task with two arguments to git log:

git log --oneline --author=test@example.org

The above command will show all commits by test@example.org. If you want to see everything from a given organisation, set the author to @example.org. Multiple --author arguments can be specified, in which case Git will show all commits which match at least one of the authors. You can substitute --committer for --author to search on the committer field instead.

The --oneline argument combines --abbrev-commit (only show a partial prefix instead of the 40-byte commit reference) and --pretty=oneline (fit commit message on one line), which makes it easier to scan a list of commits, and also to pipe the output through another command such as wc. For example, the following command run in a copy of the Linux kernel repository will show the number of commits by Microsoft employees:

git log --pretty=oneline --author=microsoft.com | wc -l

1037 commits at the time of writing – quite a lot for a company whose CEO at the time described Linux as a ‘cancer’ (The Register, Slashdot).

The only thing you should be aware of is that these commands search against the metadata for commits, which is not guaranteed to be accurate. For example,  some employees might submit patches from their personal email address instead of their work account, thus reducing the number of commits which appear to be authored by their employer.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.