Update git commit author date when amending

后端 未结 5 1492
北恋
北恋 2020-12-12 08:48

I found myself amending my commits quite often. I don\'t stash so much because I tend to forget I did so, especially when I want to save what I did before I lea

5条回答
  •  有刺的猬
    2020-12-12 09:19

    You can change the author date with the --date parameter to git commit. So, if you want to amend the last commit, and update its author date to the current date and time, you can do:

    git commit --amend --date="$(date -R)"
    

    (The -R parameter to date tells it to output the date in RFC 2822 format. This is one of the date formats understood by git commit.)

提交回复
热议问题