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

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

问题描述

是否可以在提交之前准备提交消息,这意味着我将在实际提交之前或在工作目录期间键入提交消息,以便我知道我正在处理的内容,并且知道此分支或提交的内容将全部关于。当我说之前时,我并不意味着在我在命令行中输入提交之前的几秒。我的意思是指在提交之后或分支开始时,以便下一次提交将自动继承队列中的消息或可能调用的内容。

自然地,我可以在提交过程中放置​​这些消息,对我来说是有区别的。我可以看到well git的参数并不意味着这一点。我只是好奇而已。



我也知道我可以给我的分支提供更多有意义的名字,但我只是想为此目的留出一点空间。

谢谢

解决方案

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

 git commit -F message.txt 

您可以准备消息提前在一个文本文件中,并在提交时使用该文件。



如果经常这样做,为它创建一个别名是有意义的,例如:

  done = commit -F message.txt 

所以你可以简单地键入 git done ,让它始终使用你的文本文件。



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

更新



-e flag也很有用,因为它允许您在提交之前编辑消息:

  git commit -eF message.txt 


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.

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.

thanks

解决方案

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

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

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.

UPDATE

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

git commit -eF message.txt

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

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