How to view commit history?

QuestionsQuestions8 SkillsProYour First Git LabOct, 29 2025
0135

To view the commit history in Git, you can use the git log command. This command displays a list of all commits in the current branch, along with details about each commit. Here’s how to use it effectively:

Basic Usage of git log

  1. View Commit History:
    git log
    
    This command will show a list of commits, displaying the following information for each commit:
    • Commit Hash: A unique identifier for the commit.
    • Author: The name and email of the person who made the commit.
    • Date: When the commit was made.
    • Commit Message: A brief description of the changes made.

Example Output

When you run git log, you might see output like this:

commit a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9 (HEAD -> master)
Author: Your Name <your.email@example.com>
Date:   Mon Aug 7 10:00:00 2023 +0000

    Add feature X to improve functionality

commit b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9a0
Author: Your Name <your.email@example.com>
Date:   Sun Aug 6 09:00:00 2023 +0000

    Fix bug in feature Y

Additional Options

  • Limit the Number of Commits:

    git log -n 5
    

    This command shows the last 5 commits.

  • One-line Summary:

    git log --oneline
    

    This option displays a simplified view, showing each commit on a single line with its hash and message.

  • Graphical Representation:

    git log --graph --oneline --decorate
    

    This command provides a visual representation of the commit history, showing branches and merges.

Summary

Using git log, you can easily view the commit history of your project, helping you understand the evolution of your codebase. If you have more questions or need further examples, feel free to ask!

0 Comments

no data
Be the first to share your comment!