Git repositories maintain a history of changes, and sometimes it is useful to identify when the initial commit of repository was made. Knowing when the initial commit occurred can be useful for documentation, audits, or any process requiring knowledge of when the repository was started. This tutorial demonstrates how to get first commit date and time in Git.
To display the date and time of the initial commit, execute the following command:
git log --max-parents=0 --format=%ai
Explanation of the command options:
--max-parents=0- selects first commit because it doesn't have parents.--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 get the Unix timestamp (e.g., 1273599840) instead of formatted date and time, run:
git log --max-parents=0 --format=%at
Leave a Comment
Cancel reply