2014-01-26 4 views
7

Der folgende Befehl zeigt einige Metadaten über die letzten git im JSON-Format begehen:Git: Show-Termine in UTC

git show --quiet HEAD --pretty=format:"{\"hash\":\"%h\", \"author\":\"%cn\", \"commit date\":\"%cd\"}" 

{ 
    "hash":"0fc0fc0", 
    "author":"Adam Matan", 
    "commit date":"Sun Jan 26 12:26:19 2014 +0200"} 
} 

Gibt es eine Möglichkeit, das Datum in der UTC/GMT Zeitzone zu präsentieren, z.B. "Sun Jan 26 10:26:19 2014"?

+1

UTC ist eine Zeitzone, kein Format. Was genau meinst du in diesem Fall mit dem UTC-Format? –

+0

@CharlesBailey Wahr, fest. –

Antwort

2

Ich sehe kein utc-Format in der log data formats (notiert this answer).

Der nächstgelegene ich von Ihrem Format erhalten ist:

git config log.date local 

C:\Users\VonC\prog\git\git\>git show --quiet HEAD --pretty=format:"{\"hash\":\"%h\", \"author\":\"%cn\", \"commit date\":\"%cd\"}" 
{"hash":"b594c97", "author":"Junio C Hamano", "commit date":"Thu Jan 23 10:00:28 2014 -0800"} 

C:\Users\VonC\prog\git\git\>git config log.date local 

C:\Users\VonC\prog\git\git\Documentation\technical>git show --quiet HEAD --pretty=format:"{\"hash\":\"%h\", \"author\":\"%cn\", \"commit date\":\"%cd\"}" 
{"hash":"b594c97", "author":"Junio C Hamano", "commit date":"Thu Jan 23 19:00:28 2014"} 

So von iso:

"Thu Jan 23 10:00:28 2014 -0800" 

Um lokale:

"Thu Jan 23 19:00:28 2014" 
3

Sie diese verwenden können:

TZ=UTC git show --quiet --date=local --format="%cd" 

Wenn Sie das Datumsformat steuern möchten, können Sie dies tun:

TZ=UTC git show --quiet --date='format-local:%Y%m%dT%H%M%SZ' --format="%cd"