Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Viewing Commit History | Introduction to Git
Git Essentials
course content

Course Content

Git Essentials

Git Essentials

1. Introduction to Git
2. More Advanced Interaction
3. Undoing Changes
4. Working with Branches in Git

book
Viewing Commit History

Understanding the commit history of a Git repository is fundamental to effective version control and collaboration. There are various commands and techniques to navigate and comprehend the commit history of a Git project, but, as for now, we’ll discuss only 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.

Let’s run git log in our project directory:

As you can see, all of the three commits we have 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

We can also limit the number of commits displayed using the git log -n command. For example, the following command will display only the 2 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:

Let’s run both of these commands in the terminal:

Note

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.

question-icon

Match the commands with the actions.

Display the entire commit history with detailed information about each commit:
Display 3 latest commits with detailed information about each commit:

Display the entire commit history with a single line per commit containing only the commit hash and message:

Click or drag`n`drop items and fill in the blanks

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 1. Chapter 11
We're sorry to hear that something went wrong. What happened?
some-alt