Skip to content
Related Articles

Related Articles

How to Use Git Log to Format the Commit History?

Improve Article
Save Article
  • Difficulty Level : Medium
  • Last Updated : 28 Feb, 2022
Improve Article
Save Article

As we know, git is a widely used version control system. The term “Version Control System” is self-explanatory which means it explains that for any repository the user may work on after its initialization. The git tracks and maintains the changes and updates made into the repository. Many organizations use git repositories to store their projects and work on them for years and develop them with the help of different developers and Testers altogether. Git helps and manages the updates along with different parameters based on which we can easily query the logs to get to the specific update which was made in the past.

Git log 

git log command is used to view the list of commit logs. The data is represented in a reverse log manner, i.e, showing the recent ones at the top and others at the bottom. The log contains details about the timestamp of the commit, the author of the commit, the branch on which the commit was made, the SHA(Secure Hash Algorithm) ID of the commit, and the commit message.

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.

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!