编写良好的 git 提交信息

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/jingxia2008/article/details/41290837

编写一个良好的 git 提交信息

提交信息

我们作一次提交,都会提交相关的修改信息,一般这些信息当时都会仔细考虑留下应该留下的那些重要信息,比如为什么需要这次提交,提交解决什么问题等。

而且我们需要好好组织这些信息,一边以后查看,因为这些跟代码一样重要,他们是历史,就像课本一样,一旦留下错误的信息或者难以理解的信息,将会对

后来者,产生非常多的麻烦。

提交信息规范

一般来说,提交信息没有什么强制性的规范,但是希望大家遵循一些基本的规则,这些规则有利于大家正确表达提交内容,留下重要的信息,而忽略那些不必要

的内容。

实例

https://github.com/torvalds/subsurface

编写一个良好的提交信息:

Also, please write good git commit messages. A good commit message
looks like this:
 
Header line: explain the commit in one line (use the imperative)
 
Body of commit message is a few lines of text, explaining things
in more detail, possibly giving some background about the issue
being fixed, etc etc.
 
The body of the commit message can be several paragraphs, and
please do proper word-wrap and keep columns shorter than about
74 characters or so. That way "git log" will show things
nicely even when it's indented.
 
Make sure you explain your solution and why you're doing what you're
doing, as opposed to describing what you're doing. Reviewers and your
future self can read the patch, but might not understand why a
particular solution was implemented.
 
Reported-by: whoever-reported-it
Signed-off-by: Your Name <youremail@yourhost.com>
 
where that header line really should be meaningful, and really should be
just one line. That header line is what is shown by tools like gitk and
shortlog, and should summarize the change in one readable line of text,
independently of the longer explanation. Please use verbs in the
imperative in the commit message, as in "Fix bug that...", "Add
file/feature ...", or "Make Subsurface..."
 
一次良好的提交信息应该包含一个信息头,尽量用一行文字总结那些必要信息

然后空下一行,

接着写下关于这次提交的具体内容,有关修复bug的背景等等,尽量表达你为什么

要做这次提交而不是你正在作什么提交。这样被人才能很好的理解而不会弄不清楚

为什么需要这个东西。所有的提交内容保持在74个字符之内,这样才能被 git log

正常的显示,而不会超过屏幕。

下面是一些: 提交者信息,或者其他信息,一般都是 git 里面需要的代码编写者或者

测试者名字和邮箱,具体参考 git 。




没有更多推荐了,返回首页