有没有办法在git commit上重用以前的注释? [英] Is there a way to reuse the previous comment on a git commit?

查看:70
本文介绍了有没有办法在git commit上重用以前的注释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时,我会进入故障排除模式,并提交/推送一些小的但单独的提交,并带有诸如在部署到Heroku期间对< something>进行故障排除"之类的注释.我想对每个提交使用相同的注释,而不必重新输入.这可能吗?

Occasionally I will drop into troubleshooting mode and commit/push a number of small but separate commits with a comment like, "Troubleshooting the <something> during deployment to Heroku." I would like to use the same comment for each commit without having to retype it. Is this possible?

推荐答案

起初,我回答:

我想git commit --reuse-message=HEAD做到了

然后我认为这不是您想要的,因此将其删除.然后生活赶上了AFK几个小时.无论如何,尽管答案已经被接受,我还是建议:

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. 修改现有文件
  2. (最终添加未跟踪的文件)
  3. git troubleshoot foo

将通过在部署到Heroku期间对 foo 进行故障排除"来提交更改(并最终添加新文件).作为提交消息.

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

这篇关于有没有办法在git commit上重用以前的注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆