How to amend a commit without changing commit mess

2019-01-16 00:01发布

Is there a way to amend a commit without vi (or your $EDITOR) popping up with the option to modify your commit message, but simply reusing the previous message?

3条回答
Bombasti
2楼-- · 2019-01-16 00:31

git commit -C HEAD --amend will do what you want. The -C option takes the metadata from another commit.

查看更多
一夜七次
3楼-- · 2019-01-16 00:43

Since git 1.7.9 version you can also use git commit --amend --no-edit to get your result.

Note that this will not include metadata from the other commit such as the timestamp which may or may not be important to you.

查看更多
Rolldiameter
4楼-- · 2019-01-16 00:43

Another (silly) possibility is to git commit --amend <<< :wq if you've got vi(m) as $EDITOR.

查看更多
登录 后发表回答