git 设置默认提交分支
Having a default commit message is really useful for a number of reasons:
出于多种原因,拥有默认的提交消息确实很有用:
- It can formalize your commit messages 它可以使您的提交消息形式化
- It serves as a good reminder for the information you should add to your commit message, like issue number 它可以很好地提醒您应添加到提交消息中的信息,例如发行号
- If you set it to "Drunk AF, don't accept this" 如果将其设置为“醉酒AF,请不要接受”
To set a default commit message on your local machine, start by executing the following from command line:
要在本地计算机上设置默认提交消息,请从命令行执行以下命令开始:
git config --global commit.template ~/.gitmessage
This tells your local git config to pull the text from ~/.gitmessage
as the default commit message. You could set the text to something like:
这告诉您本地的git配置将~/.gitmessage
的文本作为默认提交消息。 您可以将文本设置为:
Fix Issue #{number}: {description}
R+: {reviewer}
Of course, if you set your commit message via git commit -m {description}
, the default will not be used, so it's a win-win!
当然,如果您通过git commit -m {description}
设置提交消息,则不会使用默认值,因此是双赢的!
git 设置默认提交分支