编写git commit消息时要遵循的标准 [英] Standard to follow when writing git commit messages

查看:75
本文介绍了编写git commit消息时要遵循的标准的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现自己管理着很多文件(超过60个但低于70个),并且到目前为止我的提交消息都遵循以下模式: 当我在layout.css上添加内容时,我的提交消息是在layout.css文件上添加了内容" ,而当我删除内容时,我的提交消息是从布局中删除了内容.css文件" .

I find myself managing very many files (over 60 but below 70) and my commit messages so far follow this pattern: when I have added something like on layout.css, my commit message is "added something on layout.css file", and when I remove something, my commit message is "removed something from layout.css file".

一行中的一些文件,我看一下我的提交提要和添加的... 已删除的... 消息占主导地位.有时,我不记得删除了什么内容或在layout.css中添加了什么内容,因为我一次进行了很多更改,因此很难提出合适的提交消息.

Some files down the line, I look at my commits feed and added... and removed... messages dominate. Sometimes I don't remember what I removed or what I added in layout.css since I make so many changes at a go and so I struggle to come up with an appropriate commit message.

我应该遵循一个标准来帮助我提交提交消息吗?

Is there a standard I should follow to help me come up with my commit messages?

推荐答案

当您仅描述已完成的工作时(在技术性但模糊的术语中,例如添加功能"),则不会为Git已经添加的内容增加太多存储在提交中.想象一下,自己在一段时间后阅读了提交消息;什么样的摘要将最有助于您记住/与其他开发人员交流更改的实质?!确切的内容取决于您的项目和过程,但是我发现这是一个很好的指南.

When you just describe what you've done (in technical yet fuzzy terms like "added a function"), you're not adding much to what Git already stores in the commit. Imagine yourself reading the commit message some time later; what kind of summary would help you most remembering / communicating to other developers the essence of that change?! The exact contents depend on your project and processes, but I find that a good guideline.

因此,首先要在提交消息(例如使消息稳定化以启用持久性")中添加上下文(为什么,而不是 how )添加了frob()函数").这需要更多的努力(您必须进行反思并思考),但它的价值不菲.

Therefore, first and foremost add context (the why, not the how) with your commit message (e.g. "frobnize the message to enable persistence") instead of "added frob() function"). It's more effort (you have to reflect and think), but it is worth so much more.

如果您想进一步了解此主题,这里有很多信息,例如彼得·哈特勒(Peter Hutterer)的这篇博客文章这张有趣的幻灯片.

If you want to explore more about this topic, there's a wealth of information, for example this blog article by Peter Hutterer or this funny slide.

这篇关于编写git commit消息时要遵循的标准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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