What is the git log command?

Git is an open-source version control system used for tracking changes in any project. It allows projects to be managed by multiple entities simultaneously. When working together, it can be important to have a log of changes made in the project.

The git log command is used to display the history of commits in any project. In this Answer, we will explore using and interpreting the git log command.

This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.

By default, the git log command displays these four things: commit message, date, author, and SHA of the commit made. However, Git provides us with flags to explore the command.

Implementation

Now that we have understood the log command, we will see a practical demonstration.

Installing git

  1. Before using git, we must ensure the version control system is installed in our terminal. We can install this with the following command:

This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.
  1. We can ensure installation with the command below:

This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.

Cloning the repository

After installing git, we need a project setup to illustrate the command by performing the following steps:

  1. We receive the repository link from GitHub.

  2. Then, we clone the repository. We can clone any repository.

This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.
  1. Next, we enter the cloned directory using the cd command.

This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.

Using the git log command

Now, our terminal is all set up for using this command. We execute the git log command inside the cloned directory, as shown below:

This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.

The git log command shows an output similar to the code snippet attached below:

This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.

We are now familiar with the default git log command and its output. Here are some flags that can help us obtain relevant information:

  • git log --oneline: This flag lets the user ignore the author and date fields. Also, because this flag shows one-liners for each commit, it shows the first seven characters of SHA and leaves the rest.

  • git log --stat: This flag displays the files modified and the number of changed lines in each commit.

  • git log --graph: This flag lets the user view the logs as a graph. This helps in getting a better overview of the historical changes.

We can also use a hybrid of these flags together. For example, git log --graph --oneline can show us a graph of one-liners. Help yourself with exploring with these flags in the terminal below. Here’s a summary of the commands for reference:

This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.

This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.

Note: Replace <link to repository> with your own git repository link and the <cloned directory name> with your cloned directory name.

Conclusion

In summary, the git log command provides valuable insights into project history. In this Answer, we covered three flags: --oneline, --graph, and --stat. To explore more options, review the git-log documentation for additional flags and functionalities.

Free Resources

Copyright ©2026 Educative, Inc. All rights reserved