Reputation: 149
I recently used git commit --reedit-message=HEAD
, to make a new commit while using most of the text from the HEAD. All went well till I observed that after committing, the new commit showed the same date stamp as the previous HEAD.
The log (pretty) looked like this
hash , auth date , message
86fb360, 2019-11-16, copied commit (committed on 2019-11-21)
6dc9583, 2019-11-16, original commit (committed on 2019-11-16)
The basic log command git log -1
also showed the old date.
Why did this happen?
How to make the actual commit date appear on the new commit when using the above command?
Upvotes: 3
Views: 438
Reputation: 94483
git commit -c @ --reset-author
--reset-author
renews the author information including timestamp.
Upvotes: 1
Reputation: 21938
That's to be expected.
From -C <commit>
section in the doc :
Take an existing commit object, and reuse the log message and the authorship information (including the timestamp) when creating the commit.
(emphasis mine)
then the -c
/ --reedit-message
references it with "Like -C, but ..."
Depending on your exact needs, what you could probably do is to --amend
that last commit and set whatever date/author or other metadata you want. If you don't alter anything though, note that the committer date will still be the moment you do the amending, not the original date, which hopefully is what you tried to obtain?
Upvotes: 1