Open In App

Use Git Log to Format the Commit History

Last Updated : 09 Oct, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

In Git, keeping track of changes and understanding the project’s history is crucial for efficient collaboration and debugging. The git log command is one of the most powerful tools available to developers for viewing and formatting commit history.

By customizing git log, you can make the output more readable, concise, and visually appealing-helping you quickly find specific commits or understand how your project evolved over time.

Formatting Commit History

Git provides a range of options to customize the format of the commit history displayed by git log. These options allow you to specify which commit metadata to include, how it should be formatted, and even add custom elements to the output.

The various options to format the git log are as follows: 

--author=<Name>

It helps to format the log for those commits only where the author was a specific user. This option helps to review any logs made by any specific user overtime on a repository.

--since=<Date> / --after=<Date>

These options help to format the log based on the timestamps and query only those commit logs which fulfill the criteria.

-n <number>

The -n option helps to limit the log commits view, i.e. only a certain number of recent commits will be displayed instead of showing a bulk of updates.

--grep=<pattern>

The --grep options help the user to search for a particular pattern or word in the whole commit history and display on those commits which consist of the pattern. This option is useful when a user is looking for updates related to a specific file or object.

--graph

The --graph option displays the updates in a graphical format, displaying the branching and the merging commits as diverging and converging graph nodes. Each commit is actually a graph node in the log graph.

--oneline

The - -oneline option is used to format the commit log in as compact as much possible way.

--all

The --all option is used to view the commit log of all branches in a single log.

Note: Although, there are various options to format the log messages. The most useful options are the above-listed ones.


Explore