Knowledge Base Administration Guide

Git command help

Git SHA

To get a full Git SHA, run:

$ git show -s --format=%H
c6065e4618b7f538edf5ca0d6b5b2fd0fe129fdd

Git commit timestamp

To get an RFC 3339 commit timestamp for a Git SHA (ie for Regression JSON model_timestamp field), replace SHA with the desired SHA.

Modern Git versions

Using git show from the current workspace:

$ git show -s --format=%cI
2022-12-10T10:29:28-08:00

Alternative with a specific SHA (or a branch name):

# Replace SHA variable with SHA, Branch name, or HEAD
$ git show -s --format=%cI SHA
2021-04-30T13:05:05-07:00

Alternative using git log:

# Replace SHA variable
$ git log SHA -1 --format=%cI

# Example
$ git log abcd1234 -1 --format=%cI
2020-02-25T21:32:59-06:00

Old Git versions

If you have an ancient version of Git without the %cI format, you can use this command:

$ date --date=@$(git log SHA -1 --format="%ct") '+%FT%T.%N%:z'
2020-02-26T03:32:59.000000000+00:00