How can I view a git log of just one user's commits?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
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
Related reading
- How can I view a git log of just one user's commits?
- How can I view an old version of a file with Git?
- How can I view prior commits with git blame?
- How can I view the Git history in Visual Studio Code?
- How can my iphone app detect its own version number?
- How can one change the timestamp of an old commit in Git?
- How can one change the timestamp of an old commit in Git?
- How can you undo the last git add?
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.