How can one change the timestamp of an old commit in Git?

后端 未结 21 2432
慢半拍i
慢半拍i 2020-11-22 08:36

The answers to How to modify existing, unpushed commits? describe a way to amend previous commit messages that haven\'t yet been pushed upstream. The new messages inherit t

21条回答
  •  悲哀的现实
    2020-11-22 08:50

    Just do git commit --amend --reset-author --no-edit. For older commits, you can do an interactive rebase and choose edit for the commit whose date you want to modify.

    git rebase -i 
    

    Then amend the commit with --reset-author and --no-edit to change the author date to the current date:

    git commit --amend --reset-author --no-edit
    

    Finally continue with your interactive rebase:

    git rebase --continue
    

提交回复
热议问题