0

So looking at How can one change the timestamp of an old commit in Git?, it's easy to change the commit date in git using something like git commit --amend --date="Wed Feb 16 14:00 2011 +0100"

Am I correct in noticing that the timestamps of the commit history in ./git/logs/refs/heads don't change though? So even if you follow the aforementioned stackoverflow post to change the commit date, the timestamp shown in the log for that commit won't match.

Is there an easy way to make them match and how?

Nona
  • 5,302
  • 7
  • 41
  • 79
  • 2
    Which timestamp? Commit date or author date? And which approach from that page did you take? – Asteroids With Wings Sep 18 '20 at 17:11
  • 1
    The files in `.git/logs/refs/heads` are not the commit history and have nothing to do iwth `git log` – Mark Adelsberger Sep 18 '20 at 17:18
  • @AsteroidsWithWings - I updated the question - I was talking about commit date. MarkAdelsberger - it seems like seems like .git/logs/refs/headsfunction could function like an "audit trail" if I'm understanding it correctly? – Nona Sep 18 '20 at 17:21
  • Not really, no. You're misunderstanding what the file is. https://git-scm.com/book/en/v2/Git-Internals-Git-References – Asteroids With Wings Sep 18 '20 at 18:02

1 Answers1

0

Before: git show defaults to HEAD and $ cat .git/HEAD shows that HEAD points to ref: refs/heads/new (branch new)

zrrbite@ZRRBITE MINGW64 /d/dev/git/test (new)
$ git show
commit d0ebbb3eb1071653b0578cfdd14c0d6a7c112b1f (HEAD -> new)
Author: Martin Kjeldsen
Date:   Fri Nov 29 00:58:01 2019 +0100

Change date:

zrrbite@ZRRBITE MINGW64 /d/dev/git/test (new)
$ git commit --amend --date="Wed Feb 16 14:00 2011 +0100"
[new 71a3966] 4
Date: Wed Feb 16 14:00:00 2011 +0100
1 file changed, 1 insertion(+), 1 deletion(-)

After:

zrrbite@ZRRBITE MINGW64 /d/dev/git/test (new)
$ git show
commit 71a3966a78e7dc046dfc4bdf91c212979cfdd348 (HEAD -> new)
Author: Martin Kjeldsen
Date:   Wed Feb 16 14:00:00 2011 +0100

Further log proof for branch new:

zrrbite@ZRRBITE MINGW64 /d/dev/git/test (new)
$ git log -1
commit 71a3966a78e7dc046dfc4bdf91c212979cfdd348 (HEAD -> new)
Author: Martin Kjeldsen
Date:   Wed Feb 16 14:00:00 2011 +0100
zrrbite
  • 1,180
  • 10
  • 22