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

后端 未结 21 2418
慢半拍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:48

    if it is previous last commit.

    git rebase  -i HEAD~2
    git commit --amend --date=now
    

    if you already push to orgin and can force use:

    git push --force 
    

    if you can't force the push and if it is pushed, you can't change the commit! .

提交回复
热议问题