3

我仍然不完全清楚 git commit 消息的编写方式。

我知道基本规则,但这一条让我很困惑。在我的实践项目中,我创建了一个登录系统和一个用户注册,但尚未在数据库中实现安全密码存储。它们仍然以纯文本形式存储索尼风格。我想在提交消息中记下这一点,但我发现自己陷入了一个奇怪的困境,即如何用命令式表达这一点。

有什么想法吗?

我个人认为,这应该包含在提交消息中,即使它是对提交中未包含的内容的声明,因为它代表了任何希望使用代码的人的重要信息,这些信息可能不明显瞥了一眼变化。

4

4 回答 4

8

一篇关于提交消息的好文章是How to Write a Git Commit Message

它的第 5 条规则确实建议使用祈使语气

命令可能听起来有点粗鲁。这就是我们不经常使用它的原因。但它非常适合 git commit 主题行。
这样做的一个原因是 git 本身在代表您创建提交时使用命令式

就您的主题而言,一个简单的“不添加 xxx”就足以完成您提交的第一部分(“肯定陈述”,命令式)。

于 2014-12-24T23:16:14.167 回答
3

我假设您正在尝试决定是否

 Don't add hashing      #1

或者

 Didn't add hashing     #2a
 Doesn't add hashing    #2b

势在必行。这真的是一道英语语法题。但要回答这个问题,我们首先需要将收缩转换回完整的形式:

 Do not add hashing        #1
 (It) did not add hashing  #2a
 (It) does not add hashing #2b

其中第一个是指令或命令……告诉人们不要添加散列。那势在必行

后两个是关于提交的简单事实陈述。他们说提交没有或没有添加散列。这不是对任何人的指示或命令,因此不是必须的。(“没有”或“没有”是正确的。这取决于您是否在编写消息的人或阅读消息的人的时间范围内解释消息。)

通过这种分析,#1 和 #2 形式在提交消息中显然意味着非常不同的东西。你的提交信息应该表达真正的意思,这比它们应该符合一些风格规则或约定要重要得多。


然而 ...

我仍然不完全清楚 git commit 消息的编写方式。

There is no single definitive authority on that topic. My recommendation would be not to sweat tears over it. Do what feels right to you. If people complain, ask them to explain in detail what you have done wrong, and try to learn. (Bear in mind that some people are never satisfied.)

于 2014-12-25T00:02:12.493 回答
1

A commit message tells us what is getting added to the source code through the given commit. The commit message is representing a change-set which will get applied on the code.

The guidelines given by many experts for example this article which mention having a summary line then a blank line and then description to the commit message.

The rule of imperative mood to be followed is only for the first summary line of the commit message. This summary line of the commit message shall only mention what change will be done if this commit is applied to the code. That is logical to be written as a imperative sentence.

The additional things to be mentioned can always be part of the description of the commit message, and you can write a paragraph or two there mentioning anything including what is not implemented. Git commit is written for documenting what change will be added by that git commit. Other architectural decisions and information are better suited in other documentation like architectural decision register, product roadmap, product development wiki. If the other information is still needed in the commit message, it shall be added to the description of the message.

于 2019-02-17T10:05:25.547 回答
0

提交消息不应包含当前变更集中尚未实现的内容的注释。相反,它应该要么;

  • 简要总结更改本身(例如创建的登录系统),或者;
  • 描述首先提示更改的任务(例如允许用户登录)
于 2014-12-24T23:09:33.193 回答