How can I determine when a git ref was created? -


this not question think is.

i want know when specific ref created. not want know author timestamp or committer timestamp is.

for example: if pull remote repo, updates local repo, want retrieve timestamps of time local repo refs created.

[remote-host]$ git show --format='%h %cd' refs/heads/master 25f2508a379adf2f8aa264afe6f7e5046943274a mon, 1 aug 2016 11:33:12 -0700  [remote-host]$ logout connection remote-host closed. [local-host]$ git fetch remote: counting objects: 165073, done remote: finding sources: 100% (1836/1836) remote: total 1836 (delta 484), reused 1374 (delta 484) receiving objects: 100% (1836/1836), 4.10 mib | 0 bytes/s, done. resolving deltas: 100% (484/484), completed 262 local objects. ... [local-host]$ git show --format='%h %cd' 25f2508a379adf2f8aa264afe6f7e5046943274a 25f2508a379adf2f8aa264afe6f7e5046943274a mon, 1 aug 2016 11:33:12 -0700  [local-host]$ date mon aug  1 11:50:44 pdt 2016 

the output want mon aug 1 11:50:44 pdt 2016 (i.e. time of fetch), not committer date correctly identical on both remote , local host.

i thought of using git reflog, output of command strangely void of timestamp info.

i don't think git tracks information you're looking for, think more accurately described "the date blob created on local system".

you could:

  • first loose blob matching content hash, , if find it, assume mtime of blob time @ created on system (since shouldn't modified subsequent operation):

    cid=25f2508a379adf2f8aa264afe6f7e5046943274a if test -f .git/objects/${cid:0:2}/${cid:2};   ls -l .git/objects/${cid:0:2}/${cid:2} fi 
  • if don't find loose object, through pack files find corresponding content id, , if find it, assume mtime of corresponding packfile date want:

    for idx in .git/objects/pack/*.idx;   if git show-index < $idx | grep $cid;     ls -l ${idx/idx/pack}     break   fi done 

Comments