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

前端 未结 4 539
滥情空心
滥情空心 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:53

    At first, I answered:

    I guess git commit --reuse-message=HEAD does it

    Then I thought that's not what you wanted and deleted it. Then life caught up and got AFK for a couple of hours. Anyways, despite an answer having already been accepted, I would have suggested:

    $ git config alias.troubleshoot '!troubleshoot() { git add -u && git commit -m "Troubleshooting the $1 during deployment to Heroku."; }; troubleshoot'
    

    And you use it the following way:

    1. modify existing files
    2. (eventually add untracked files)
    3. git troubleshoot foo

    Would commit changes (and eventually new files) with "Troubleshooting the foo during deployment to Heroku." as commit message.

提交回复
热议问题