![]() |
In collaborative software development, it’s often necessary to view the commit history of individual contributors. Git provides powerful tools to filter and examine commits based on various criteria, including the author. This guide will walk you through the steps to view the Git log of one user’s commits. PrerequisitesSearch by UsernameThe most common way is using the `–author` option with `git log`: git log --author="<username>"
![]() Replace “ with the actual name of the developer whose work you want to see. Partial Username Search: `–author` allows searching by a part of the username: git log --author="htom*" # This shows commits by users starting with "htom"
Note : By default, `git log` only shows commits from the current branch. To include all branches: git log --author="<username>" --all
By using these options with `git log`, you can easily filter the commit history and focus on a specific developer’s contributions to your Git project. Customize the OutputThe default git log shows commit hashes and messages. You can customize the format for better readability: Format String:git log --author="Author Name" --pretty=format:"%h - %an, %ar : %s"
This displays:
Fuller Details:git log --author="Author Name" --pretty=fuller
This shows more information about each commit, including author and committer details, date, and the full commit message. ![]() –pretty variations Limiting the Number of Commits:To see only a specific number of commits (e.g., the last 10), use the -n option: git log --author="Author Name" -n 10
This shows only the most recent 10 commits by the specified author. Filtering by Commit Message: git log --author="<username>" --grep="fix bug"
This shows commits by the specified author containing the phrase “fix bug” in the message. Filtering by Date Range:
For more Git log filters visit : Git Log filters |
Reffered: https://www.geeksforgeeks.org
Git |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 12 |