Git
User Commits
Version Control
Software Development
Git Log
How can I view a git log of just one user's commits?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
Git's --author flag filters the commit log to show only commits by a specific person. This is useful for code reviews, tracking individual contributions, generating reports, and understanding who changed specific parts of a codebase.
Basic Usage
Replace "username" with the name or email of the user. The --author flag performs a pattern match, so partial names work:
Formatting Options
One-Line Summary
With Date and Stats
Custom Format
Common format placeholders:
| Placeholder | Output |
%H | Full commit hash |
%h | Short commit hash |
%an | Author name |
%ae | Author email |
%ad | Author date |
%s | Subject (first line of message) |
%b | Body of commit message |
Filtering by Date Range
Filtering by File or Directory
Counting Commits
Searching Commit Messages
Combine --author with --grep to find specific commits:
Multiple Authors
Author vs Committer
Git tracks two identities per commit:
- Author: who wrote the change (set by
git commit --author) - Committer: who applied it (set by
GIT_COMMITTER_NAME)
After a rebase or cherry-pick, the committer may differ from the author.
Useful Aliases
Common Pitfalls
- Case sensitivity: The
--authorflag is case-sensitive by default."alice"will not match"Alice". Add-ifor case-insensitive matching:git log --author="alice" -i. - Multiple identities: Users may commit with different names or emails across machines. Search by partial email domain:
git log --author="@company.com". - Regex matching: The
--authorvalue is a regex pattern. Special characters like.match any character. Escape them:git log --author="alice\.johnson". - Branch scope: By default,
git logonly shows the current branch. Add--allto search across all branches. - Merge commits:
git log --author="Alice"includes merge commits. Add--no-mergesto exclude them.
Summary
- Use
git log --author="name"to filter commits by a specific user - The
--authorflag matches against both name and email using regex - Combine with
--since,--until,--grep, and-- pathfor precise filtering - Use
git shortlog -snfor commit count summaries per author - Add
-ifor case-insensitive matching and--no-mergesto exclude merge commits

