How Can I View a Git Log of Just One User’s Commits?

Better Stack Team
Updated on July 25, 2024

To view a Git log of just one user's commits, you can use the --author flag with the git log command. This allows you to filter the commit history to show only those commits made by a specific author. Here’s how you can do it:

Viewing Git Log of One User's Commits

  1. Open Your Terminal or Command Prompt: Start by opening your terminal or command prompt where your Git repository is located.
  2. Use git log with -author Option: Use the following command to view the commit history for a specific user:

     
    git log --author="John Doe"
    

    Replace "John Doe" with the name or email of the user whose commits you want to view.

 
- **Example 1: Viewing by Name:**

    ```bash
    git log --author="John Doe"
    ```

- **Example 2: Viewing by Email:**

    ```bash
    git log --author="john.doe@example.com"
    ```
  1. Additional Options:
    • Date Ranges: You can also specify date ranges using -since and -until options to further filter the log output.
    • Format: Use -pretty to customize the log output format (-pretty=oneline, -pretty=format:"%h %s", etc.).

Example Usage

Let’s say you want to view the commit history of the user "John Doe":

 
git log --author="John Doe"

This command will list all commits made by "John Doe" in reverse chronological order (most recent first).

Notes:

  • Exact Match: The -author option matches the entire author string exactly. If you are unsure of the exact name or email format, you may need to check the commits or use partial matches cautiously.
  • Case Sensitivity: The author matching is case-sensitive. Ensure the name or email is specified correctly.
  • Combining Filters: You can combine -author with other git log options (like -since, -until, etc.) to further refine the commit history output.

By using git log --author, you can easily filter and view the commit history of a specific user within your Git repository. This is useful for reviewing contributions or investigating changes made by individual team members.

Got an article suggestion? Let us know
Explore more
Git
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Make your mark

Join the writer's program

Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.

Write for us
Writer of the month
Marin Bezhanov
Marin is a software engineer and architect with a broad range of experience working...
Build on top of Better Stack

Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.

community@betterstack.com

or submit a pull request and help us build better products for everyone.

See the full list of amazing projects on github