更新时间:2022-11-15 21:01:32
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