Search code examples
gitgit-commit

How to edit the commit date when using git commit --reedit-message?


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 -1also 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?


Solution

  • git commit -c @ --reset-author
    

    --reset-author renews the author information including timestamp.