在提交之前准备git commit消息? [英] Preparing a git commit message before committing?

查看:67
本文介绍了在提交之前准备git commit消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在提交之前准备提交消息,这意味着我将在实际提交之前或在工作目录中键入提交消息,以使我知道自己在做什么,并且知道该分支或提交是什么会全力以赴.当我说之前"时,我并不是说在命令行上输入提交之前几秒钟.我的字面意思是在提交之后或分支的开始处,以便下一次提交将自动继承队列中的消息或可能调用的消息.

Is it possible to prepare a commit message prior to a commit, meaning that I will type my commit message before the actual commit or during the working dir so that I know what I am working on and I know what this branch or commit will be all about. When I say "before" I do not mean just couple secs before I enter the commit on the commandline. I literally mean right after a commit or at the starting of a branch so that the next commit will automatically inherit the message in the queue or what ever that might be called.

自然地,我可以在提交过程中放置​​这些消息,对我来说是有区别的.我可以看到,关于git well的说法也不是这个意思.我对此很好奇.

Naturally I can put these messages during the commit, to me there is a difference. And I can see the argument of well git is not meant for that as well. I am just curious about it.

我也知道我可以给分支赋予更多有意义的名称,但我只想为此留一点空间.

I also know I can give my branches more meaningful names but I just want a bit space for such purpose.

推荐答案

Git可以使用-F--file标志从文件中获取提交消息:

Git can take the commit message from a file using the -F or --file flags:

git commit -F message.txt

您可以预先在文本文件中准备消息,并在提交时使用该文件.

You can prepare your message in advance in a text file and use that file when you commit.

如果经常执行此操作,则可以为其创建一个别名,例如:

If you do this often, it makes sense to create an alias for it, for example:

done = commit -F message.txt

这样您就可以简单地键入git done使其始终使用您的文本文件.

So that you can simply type git done to have it always use your text file.

如果您犯了一个错误并且在没有更新消息文件的情况下提交得太快(不是问题),则可以执行git commit --amend并在提交中修复消息.

If you make a mistake and commit too fast without updating the message file, not a problem, you can just do git commit --amend and fix the message in the commit.

更新

-e标志也很有用,因为它使您可以在提交之前编辑消息:

The -e flag is useful too, as it lets you edit the message before committing:

git commit -eF message.txt

这篇关于在提交之前准备git commit消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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