Get Last Commit Date and Time in Git

Get Last Commit Date and Time in Git

Git tracks every change made in a repository, and sometimes it can be useful to determine when the most recent commit was created. This information can be valuable for monitoring ongoing development activity, confirming that recent updates have been applied, as well as for auditing or other purposes. This tutorial explains how to get last commit date and time in Git.

To display the date and time of the most recent commit, run the following command:

git log -1 --format=%ai

Explanation of the command options:

  • -1 - limits the output to only the latest commit.
  • --format=%ai - formats the output to show the date and time in ISO 8601 format (e.g., 2010-05-11 17:44:00 +0000).

To retrieve the Unix timestamp (for example, 1273599840) rather than a human-readable date and time, execute:

git log -1 --format=%at

Leave a Comment

Cancel reply

Your email address will not be published.