如何写良好的提交消息

Writing good commit messages

 

Good commit messages serve at least three important purposes:

好的提交消息至少服务于3个重要的目的:

  • To speed up the reviewing process.
  • 加速代码审查的进程。
  • To help us write a good release note.
  • 帮助我们写一个好的版本说明。
  • To help the future maintainers of Erlang/OTP (it could be you!), say five years into the future, to find out why a particular change was made to the code or why a specific feature was added.
  • 帮助将来的Erlang/OPT维护者(可能会是你),在将来的5年中,找出代码为什么回做一个特别的改变的原因或者增加了一个特定的特性。

Structure your commit message like this:

你提交的信息结构像这样:

Summarize clearly in one line what the commit is about
用一句话总结提交的是关于什么。
Describe the problem the commit solves or the use
case for a new feature. Justify why you chose
the particular solution.
描述提交解决的问题或者新特新的用例。证明为什么你选择这个特定的解决方案。

DO

  • Write the summary line and description of what you have done in the imperative mode, that is as if you were commanding someone. Write “fix”, “add”, “change” instead of “fixed”, “added”, “changed”.
  • 写总结并且在命令行模式中描述你已经做的,这就好像你是在命令别人。
  • 写“fix”,“add”,“change”,代替”fixed”,”added”,”changed”.
  • Always leave the second line blank.
  • 总是留下空白的第2行。
  • Line break the commit message (to make the commit message readable without having to scroll horizontally in gitk).
  • 用行打段提交消息(使提交消息可读不需要不得不水平滚动在gitk中).

DON’T

  • Don’t end the summary line with a period.
  • 没明白…

Tips

  • If it seems difficult to summarize what your commit does, it may be because it includes several logical changes or bug fixes, and are better split up into several commits using git add -p.
  • 如果它看起来很难总结你的提交是做什么的,可能是因为它包含了几个逻辑改变或者bug修复,最好分离这几个提交用git add –p.

References

The following blog post has a nice discussion of commit messages:

下面的blog帖子是一个很好的提交信息的讨论。

posted @ 2013-01-07 22:19  sqtds  阅读(250)  评论(0编辑  收藏  举报