我应该在git commit消息中使用过去或现在式吗? [英] Should I use past or present tense in git commit messages?

查看:137
本文介绍了我应该在git commit消息中使用过去或现在式吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

阅读过一次,git commit消息应该处于必要的现在时态。 为x添加测试。我总是发现自己使用过去式,例如虽然增加了对x的测试,但这对我来说更自然。



下面是最近的John Resig提交,其中显示了两条消息:


调整一些更多jQuery在操作测试中设置结果。还修复了预期测试结果的顺序。

这有什么关系吗?我应该使用哪一个?

解决方案

现在时,命令式的提交消息的偏好来自Git本身。从文档/ SubmittingPatches 在Git repo中:


描述你在命令式情绪中的变化,例如make xyzzy do frotz
而不是[这个补丁]让xyzzy做frotz或者[我]改变了xyzzy
来做frotz,就好像你正在给代码库下令改变
其行为。

所以你会看到很多用这种风格编写的Git commit消息。如果你在一个团队或开源软件上工作,如果每个人都坚持这种风格以保持一致性,那么这很有帮助。即使你正在开展一个私人项目,并且你是唯一一个能够看到你的git历史的人,但使用必要的情绪会很有帮助,因为它确立了良好的习惯,当你与他人一起工作时,这些习惯会得到欣赏。

I read once that git commit messages should be in the imperative present tense, e.g. "Add tests for x". I always find myself using the past tense, e.g. "Added tests for x" though, which feels a lot more natural to me.

Here's a recent John Resig commit showing the two in one message:

Tweak some more jQuery set results in the manipulation tests. Also fixed the order of the expected test results.

Does it matter? Which should I use?

解决方案

The preference for present-tense, imperative-style commit messages comes from Git itself. From Documentation/SubmittingPatches in the Git repo:

Describe your changes in imperative mood, e.g. "make xyzzy do frotz" instead of "[This patch] makes xyzzy do frotz" or "[I] changed xyzzy to do frotz", as if you are giving orders to the codebase to change its behavior.

So you'll see a lot of Git commit messages written in that style. If you're working on a team or on open source software, it is helpful if everyone sticks to that style for consistency. Even if you're working on a private project, and you're the only one who will ever see your git history, it's helpful to use the imperative mood because it establishes good habits that will be appreciated when you're working with others.

这篇关于我应该在git commit消息中使用过去或现在式吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆