Is there a way to reuse the previous comment on a git commit?

前端 未结 4 523
滥情空心
滥情空心 2020-12-30 02:34

Occasionally I will drop into troubleshooting mode and commit/push a number of small but separate commits with a comment like, \"Troubleshooting the during

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-30 02:52

    I'm not sure of how you can have a certain set of git commits use the last git comment you had entered, but you can set a default commit message. That could do the trick as long as you unset the default commit message once you're done with all the commits that needed to use that message.

    Here's how you go about setting a default commit message. First, enter the desired commit message in a file, lets call it ~/LastCommitMessage.txt. Then, specify this as your default (global) commit message like so:

    $ git config --global commit.template ~/LastCommitMessage.txt
    

    You could narrow the scope by not using --global and using something else instead.

    You can easily access all git settings by opening up the .gitconfig file located in your home directory. Open up that file and delete the setting above to unset it once you're done with all your commits.

提交回复
热议问题