TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

What a good commit message looks like (2011)

96 点作者 ziodave超过 8 年前

18 条评论

chris_7超过 8 年前
<p><pre><code> 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 &quot;git log&quot; will show things nicely even when it&#x27;s indented. </code></pre> Software should help me, I shouldn&#x27;t have to help it. Why doesn&#x27;t git handle this formatting automatically? I shouldn&#x27;t need to manually break lines for typographical (not paragraph) reasons.
评论 #13492652 未加载
评论 #13492772 未加载
评论 #13492958 未加载
评论 #13493047 未加载
wruza超过 8 年前
Just for those who are tired of sites that disable both 2tap-zoom and &#x27;pre&#x27; block wrapping on mobile.<p>---<p>A good commit message looks like this:<p>Header line: explaining the commit in one line<p>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.<p>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 &quot;git log&quot; will show things nicely even when it&#x27;s indented.<p>Reported-by: whoever-reported-it<p>Signed-off-by: Your Name &lt;youremail@yourhost.com&gt;<p>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.
struppi超过 8 年前
Recently, I try to write the first line of my commit messages so they describe what the system now does, compared to before the commit. This makes reading the history much more fun. Like:<p><pre><code> Validation of email addresses now sends a test email to the user, instead of the old regex that never worked. </code></pre> This style does not work for all kinds of changes, but when it works, it creates a nice history of how the functionality of the system grew...
评论 #13492553 未加载
评论 #13492511 未加载
svckr超过 8 年前
Here&#x27;s what, Tim Pope, our favourite vim nerd has to say about this: <a href="http:&#x2F;&#x2F;tbaggery.com&#x2F;2008&#x2F;04&#x2F;19&#x2F;a-note-about-git-commit-messages.html" rel="nofollow">http:&#x2F;&#x2F;tbaggery.com&#x2F;2008&#x2F;04&#x2F;19&#x2F;a-note-about-git-commit-messa...</a> (Same, but with more words.)<p>A point of contention seems to be the choice of the imperative, at least for the subject line. While I&#x27;m really used to it, both when reading and writing, many people seem to <i>strongly</i> prefer past tense (&quot;Fixed bug …&quot; instead of &quot;Fix bug …&quot;).
评论 #13492762 未加载
评论 #13492710 未加载
评论 #13492720 未加载
binarnosp超过 8 年前
I open an issue for every feature, bug or enhancement, then I mention the issue in the commit followed by a short description of the changes. I wrote down a procedure that I follow for every commit [1].<p>This allows me to keep the commit line short and to see the commits history related to the resolution of a bug or feature.<p>When using Gitlab, Bitbucket or Github the issues and the commits are cross-linked (example: [0]).<p>[0] <a href="https:&#x2F;&#x2F;bitbucket.org&#x2F;binarno&#x2F;imebra&#x2F;issues&#x2F;162&#x2F;" rel="nofollow">https:&#x2F;&#x2F;bitbucket.org&#x2F;binarno&#x2F;imebra&#x2F;issues&#x2F;162&#x2F;</a> [1] <a href="https:&#x2F;&#x2F;imebra.com&#x2F;wp-content&#x2F;uploads&#x2F;documentation&#x2F;html&#x2F;sop.html#sop-fixbug-2-fixing-a-bug" rel="nofollow">https:&#x2F;&#x2F;imebra.com&#x2F;wp-content&#x2F;uploads&#x2F;documentation&#x2F;html&#x2F;sop...</a>
mojuba超过 8 年前
Should be noted, it is often tempting to describe everything about the change in the commit description rather than comments in the code. Remember, git commits disappear from sight pretty soon and become fossils, whereas there may be something important that should be said in the code itself.
评论 #13492577 未加载
评论 #13492586 未加载
评论 #13492692 未加载
评论 #13494007 未加载
评论 #13492606 未加载
gempir超过 8 年前
Great system about our commit system at work is that every commit starts with the name of a ticket of our ticket system (jira) so you can go back to that ticket whenever that commit comes up anywhere and understand the commit better
评论 #13492596 未加载
abstractbeliefs超过 8 年前
For those who aren&#x27;t familiar with the kernel process, what&#x27;s the Reported-by line? Simply the reporter of any original bug that the patch was written to fix?<p>I understand that the Signed-off-by line is equivalent to a CLA, right?
评论 #13492351 未加载
评论 #13492342 未加载
评论 #13492355 未加载
评论 #13492341 未加载
jordansmithnz超过 8 年前
Nice. At an old job, I got a little bored, so I&#x27;d spend time crafting wonderful commit messages. Most of them contained puns, some very subtle, some less so.<p>In regards to commit ethos, I&#x27;m not sure I agree with all of the statements made. To me, something simple&#x2F;concise, that others will understand, but not lacking in key info, is much better than several paragraphs explaining the same thing.
leotartari超过 8 年前
This is still relevant, as my friend Cesar wrote about it just the other day (with a very similar title) » <a href="https:&#x2F;&#x2F;hackernoon.com&#x2F;what-makes-a-good-commit-message-995d23687ad#.5sc2xvg92" rel="nofollow">https:&#x2F;&#x2F;hackernoon.com&#x2F;what-makes-a-good-commit-message-995d...</a>
collyw超过 8 年前
One problem with this is that git gets used as a deployment tool as well as a version control system.<p>Trying to get something to run on Heroku involved making lots of small changes just to get things to run on the server the same as on my dev machine.<p>When you do that 10 or 20 times the commit message become somewhat meaningless.
评论 #13492910 未加载
评论 #13493504 未加载
msimpson超过 8 年前
The link within that README leading to what &quot;Signed-off-by&quot; means is now broken. Use:<p><a href="https:&#x2F;&#x2F;gerrit-review.googlesource.com&#x2F;Documentation&#x2F;user-signedoffby.html" rel="nofollow">https:&#x2F;&#x2F;gerrit-review.googlesource.com&#x2F;Documentation&#x2F;user-si...</a>
dallamaneni超过 8 年前
I made this git commit template sometime ago. Check it out if it is of any help: <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;adeekshith&#x2F;cd4c95a064977cdc6c50" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;adeekshith&#x2F;cd4c95a064977cdc6c50</a>
__strisk超过 8 年前
don&#x27;t use git commit messages as &quot;dear diary&quot; sort of things.<p>For example:<p>&quot;I fixed the button issue on the homepage. Still, need to center the title.&quot;<p>would be better written as:<p>&quot;fixes button issue on homepage&quot;<p>Always think about what that commit does to the codebase. This is obviously for single-line commits. I suppose it would be okay to &quot;dear diary&quot; in the commit body. You can provide rationality or context in the commit body.
评论 #13495282 未加载
fit2rule超过 8 年前
My commit messages are (usually) one-line, starting early in the sentence with the focus of the effort, and ending with a clear statement of what happened.
StapleHorse超过 8 年前
Relevant xkcd <a href="https:&#x2F;&#x2F;xkcd.com&#x2F;1296" rel="nofollow">https:&#x2F;&#x2F;xkcd.com&#x2F;1296</a><p>I once wrote &quot;commit&quot;. A fellow coworker still makes fun of me for that, joking of course.
dang超过 8 年前
Url changed from <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;matthewhudson&#x2F;1475276" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;matthewhudson&#x2F;1475276</a>, which (kind of) points to this.
Avshalom超过 8 年前
&gt;74 characters<p>path dependency is hell of a drug.
评论 #13492427 未加载
评论 #13492361 未加载
评论 #13493239 未加载