Home Writing Reading

til / Exact time of a git commit

Yesterday I was combining my blog and TIL posts and I wanted to find out the exact time of a git commit. It turns out that it’s really easy. If you hover the date of a commit in GitHub, you’ll see the full date and time.

exact-commit-time

If you want an even more precise time that includes seconds or if you want to get the time using the terminal, you can use the following command.

git show -s --format=%ci <commit-sha>
# 2022-02-23 13:27:44 +0100
  • -s – Removes the diff
  • --format=%ci - Only display the date in an ISO 8601-like format (use %cI if you need strict ISO 8601-format)

  • Loading next post...
  • Loading previous post...