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

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

    From the git-commit(1) command documentation,

    -C 
    --reuse-message=
    Take an existing commit object, and reuse the log message and the authorship 
    information (including the timestamp) when creating the commit.
    
    -c 
    --reedit-message=
    Like -C, but with -c the editor is invoked, so that the user can further edit 
    the commit message.
    

    It's then possible using,

      git commit --reuse-message=HEAD
    

    Update:

    You may also need to use the --reset-author option,

    --reset-author
    When used with -C/-c/--amend options, declare that the authorship of the 
    resulting commit now belongs of the committer. This also renews the author 
    timestamp.
    

提交回复
热议问题