Py学习  »  Git

为将来的git提交设置提交消息

Mei Zhang • 5 年前 • 1923 次点击  

有没有办法使用git为下一次提交设置注释想象一下这样的情景:

git next-commit "Implement client-side validation"

# implement the feature ...

# commit changes
# equivalent to git commit -m "Implement client-side validation"
git commit -m from-next-commit

这背后的动机是,我经常有一个特定的特点时,我在编程,但在途中我最终开发一些其他功能或固定相关的东西,我失去了我的主要任务的轨道。

在那一点上,我已经用有用的修改修改了源代码,但是我甚至不记得我添加的主要功能是什么,因为这只是一堆修改,我能想到的唯一提交消息是 git commit -m "Update stuff" . 为下一次提交设置消息也可以帮助我继续处理我应该做的事情在任何时候,如果我觉得我忘记了主要的任务,并且偏离了其他特性,那么我最好问git git next-commit ,可以打印 Implement client-side validation .

像这样的特征存在吗?

编辑:看到一些答案后,我想我应该澄清另一件事理想情况下,此命令还可以帮助您跟踪何时已经使用了将来的提交例如,如果使用 git commit -m from next-commit 两次未设置新的未来提交消息之前,它应该失败。

$ git next-commit "Implement client-side validation"
ok
$ git commit -m from-next-commit
ok
# git commit -m from-next-commit
error : already used
$ git next-commit "Optimize get_request"
ok
$ git commit -m from-next-commit
ok
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/49210
 
1923 次点击  
文章 [ 4 ]  |  最新文章 5 年前