# command 1git log -1 --date=iso-strict --format=%cd --date=unix <commit-hash> | xargs -I{} date -u -d @{} +"%Y-%m-%dT%H:%M:%SZ"# command 2git log -1 --format=%ct <commit-hash> | xargs -I{} date -u -d @{} +"%Y-%m-%dT%H:%M:%SZ"也可以封装为一个 bash 脚本:
#!/usr/bin/env bash# Save as check-git-commit-time.sh# Usage: ./check-git-commit-time.sh <commit-hash>
if [ -z "$1" ]; then echo "Usage: $0 <commit-hash>" exit 1fi
commit="$1"
# Get the commit's Unix timestamptimestamp=$(git log -1 --format=%ct "$commit")
# Convert to UTC ISO 8601 formatdate -u -d @"$timestamp" +"%Y-%m-%dT%H:%M:%SZ"