Git

How to Configure “git log” to Show “commit date”?

In Git, a “commit date” refers to the date and time of the specific commit when it was made to the particular repository. When developers make and commit changes, Git records the date and time of the commit. These records can be seen later by anyone with access to the particular repository. Sometimes, you may want to view the commit date to know when changes were made to the code by other team members. More specifically, it helps you to track progress and debug issues in the code.

This article will explain the procedure of configuring the “git log” to show the “commit date”.

How to Configure “git log” to Show/Display “commit date”?

Different options can be utilized with the “git log” command to show the “commit date”, such as:

Method 1: Configure “git log” Using “–pretty=fuller” Option

The “–pretty=fuller” option is used to show the detailed information about the Git commits. Utilize this option with the “git log” command to view the author name, author date, commit hash, message, and commit date:

git log --pretty=fuller

 
In the below output, the highlighted part represents the commit date:

Method 2: Configure “git log” Using “–pretty=format” Option

The “–pretty=format” option is utilized to define different formats to get the output in the desired format. Use this option with the “git log” command and specify desired formats to show the commit date along with the commit hash and commit message:

git log --pretty=format:'%h (%cs) %s'

 
Here:

    • %h” option displays the commit hash.
    • %cs” option shows the commit date.
    • %s” is used to view the commit message.

You can see the commit date in the below screenshot:


That was all about showing the “commit date” using the “git log” command.

Conclusion

Git provides various options with the “git log” command to show the “commit date”, such as the “–pretty=fuller” and “–pretty=format”. The “–pretty=fuller” option displays the commit hash, commit message, commit date, author name, author email, etc. However, the “–pretty=format” option can be used with different formats to get the output in a specific format. This article explained the method to configure the “git log” to display the “commit date”.

About the author

Laiba Younas

I have done bachelors in Computer Science. Being passionate about learning new technologies, I am interested in exploring different programming languages and sharing my experience with the world.