Viewing Commit History
Understanding the commit history of a Git repository is essential for effective version control and collaboration.
There are several commands and methods to explore and interpret a Git project's history, but for now, focus on the git log
command.
Git Log
The primary command for viewing commit history is git log
. This command displays a chronological list of commits, providing essential information for each commit.
Basic Usage
This command displays the commit history from the latest to the earliest. You can navigate through the log using arrow keys and exit by pressing q.
Run the git log
command in the project directory:

As you can see, the three commits made so far are displayed.
Output Details
Despite the output taking rather few lines, it contains quite a lot of information for each commit. Here are these elements (from top to bottom):
- commit hash (unique commit identifier);
- author (name and email of the person who made the commit);
- date and time the commit was made;
- commit message.
Customizing the Output
You can limit the number of commits displayed with the git log -n
command.
For instance, the following command shows only the two latest commits:
Moreover, it is possible to condense each commit to a single line, showing only the commit hash and the commit message using the following command:
Run both commands in the terminal:

When running the git log --oneline
command the hashes of the commits are not displayed entirely. Instead, only the symbols, which uniquely identify the commit, are displayed.
Thanks for your feedback!
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
What other options can I use with the `git log` command?
How can I search for a specific commit in the log?
Can you explain the difference between `git log` and `git log --oneline`?
Awesome!
Completion rate improved to 3.57
Viewing Commit History
Swipe to show menu
Understanding the commit history of a Git repository is essential for effective version control and collaboration.
There are several commands and methods to explore and interpret a Git project's history, but for now, focus on the git log
command.
Git Log
The primary command for viewing commit history is git log
. This command displays a chronological list of commits, providing essential information for each commit.
Basic Usage
This command displays the commit history from the latest to the earliest. You can navigate through the log using arrow keys and exit by pressing q.
Run the git log
command in the project directory:

As you can see, the three commits made so far are displayed.
Output Details
Despite the output taking rather few lines, it contains quite a lot of information for each commit. Here are these elements (from top to bottom):
- commit hash (unique commit identifier);
- author (name and email of the person who made the commit);
- date and time the commit was made;
- commit message.
Customizing the Output
You can limit the number of commits displayed with the git log -n
command.
For instance, the following command shows only the two latest commits:
Moreover, it is possible to condense each commit to a single line, showing only the commit hash and the commit message using the following command:
Run both commands in the terminal:

When running the git log --oneline
command the hashes of the commits are not displayed entirely. Instead, only the symbols, which uniquely identify the commit, are displayed.
Thanks for your feedback!