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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Subject-First Commit Messages

151 点作者 s4i超过 1 年前

32 条评论

hn_throwaway_99超过 1 年前
TBH, at least at every company I&#x27;ve worked at recently, the style of the commits is more or less irrelevant to me save for one very important piece: The commit starts with the ID of the ticket for the code change (or some placeholder for very small commits where a ticket wasn&#x27;t necessary, e.g. [no-tix]). The biggest benefit of this is that these commits can then be automatically linked to the ticket which often has a lot more detail and conversation.<p>99% of the time when I&#x27;m looking at commit history, I&#x27;m not just generically scanning. I&#x27;m usually looking for a particular change, or when something touched a particular file, etc. Even the example given in the linked page isn&#x27;t really relevant to me, because I&#x27;m rarely &quot;quickly scanning&quot; a whole commit log for something in particular - I&#x27;d always just use a search feature (in GitHub or some git IDE plugin) for that.
评论 #38835719 未加载
评论 #38836522 未加载
评论 #38836594 未加载
评论 #38836546 未加载
评论 #38835737 未加载
评论 #38842815 未加载
评论 #38838268 未加载
评论 #38835724 未加载
twodave超过 1 年前
I look at commit messages every day. I actually don&#x27;t love a message that just describes the code change (I can figure that out on my own if I look at it long enough). That&#x27;s fine for bigger or more misleading changes, but when I&#x27;m looking at blame&#x2F;history I&#x27;m usually very aware of what the code is doing already. My question at those times is less about &quot;what&quot; and more about &quot;why&quot;. Why was this change made? Sometimes that can be found by looking at accompanying tests (if the original author was so gracious), but if it&#x27;s not in the commit (or only obtusely so, as many developers I know tend to commit in what I&#x27;ll call &quot;stream-of-consciousness&quot; style) then I&#x27;ve got to go outside the codebase to research by interviewing people (assuming they&#x27;re still around and remember) or trawling through our project management system to try and line up released features&#x2F;fixes with the change. It quickly becomes an inexact science.<p>That said, in my experience, the larger an organization, the more commit messages get looked at. On my side projects where only 1-3 people are involved, commit messages only really show up on the PRs as things are going in. Sometimes we complete our own PRs to keep up the velocity since we&#x27;re all working async part-time. Rarely if ever do we look back to figure out why we did something because the project is so small.
评论 #38832567 未加载
评论 #38832482 未加载
评论 #38835468 未加载
评论 #38835677 未加载
r3trohack3r超过 1 年前
I personally prefer conventional commits.<p><a href="https:&#x2F;&#x2F;www.conventionalcommits.org&#x2F;en&#x2F;v1.0.0&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.conventionalcommits.org&#x2F;en&#x2F;v1.0.0&#x2F;</a><p>The subject line says what the purpose of the change is (CI&#x2F;CD, tests, bug fix, new feauture), what component it primarily focuses on, and then a plain text one line summary.<p>For example:<p><pre><code> ci(GitLab): Add rust build directory to cache This should improve build times by caching most of the compile tree between builds. In testing, I’ve observed builds drop from 2m to 30s when scheduled on a node with a primed cache. </code></pre> It also forces me to keep my commits focused. If I can’t create a one line summary of what I’ve done, it probably needs to be broken up into multiple commits.
评论 #38853759 未加载
评论 #38836414 未加载
评论 #38836717 未加载
rco8786超过 1 年前
I think I would prefer this style.<p>And also the discourse around commit messages and their various flavors may be one of the biggest wastes of time in terms of ROI in our industry.<p>I’ve been doing this for 14-15 years and can probably count on two hands the number of times I’ve needed to look at historical commit messages.
评论 #38832525 未加载
评论 #38832275 未加载
评论 #38832552 未加载
评论 #38832229 未加载
评论 #38832512 未加载
评论 #38832236 未加载
评论 #38836570 未加载
gherkinnn超过 1 年前
The subject-first style felt grating at first, but comparing the two I found myself reading more per line than I did in the verb-first approach.<p>Fix <i>skip</i> fix <i>skip</i> fix <i>skip</i> add <i>skip</i><p>I knew nothing at the end. The second style had me grasp more, as there were no obvious hooks to skip without knowing what had changed.<p>But as others have said, commit messages are a cesspool of bikeshedding and ultimately useless, unless every commit is a self-contained chunk of work which it rarely is.<p>On the side, I enjoyed all of this author&#x27;s thoughts in the repo. Good find.
评论 #38836504 未加载
minimaul超过 1 年前
I like a style like:<p>codebase section: short summary<p>longer description if necessary<p>eg: cocoaui: fix images being incorrectly aligned on high dpi displays<p>We were calculating the position of the image in logical pixels, but not converting that to actual display pixels for rendering.<p>I think it&#x27;s a really nice style that makes commit messages really easy to scan in a short log, and lets you ignore commits easily that don&#x27;t touch the area you&#x27;re interested in
andai超过 1 年前
Spent 5 minutes trying to figure out where field_name is in the second list... I thought it was the same commits rewritten to be more scannable, but they are from a different project.<p>(I scanned, naturally, the article itself!)<p>Or more generally, I thought the point of the article would be that the function &#x2F; variable names from the first list would be moved to the beginning of sentences. But in the 2nd example they are completely absent, favoring much vaguer &#x2F; high level descriptions. So we are unable to see the before&#x2F;after effect for the same list of commits, I think most of the potential impact of the author&#x27;s intended point is lost.<p>(Also, the first half extolls the virtues of being able to read quickly, while the second half tells you to use longer sentences for everything for apparently no reason?)
评论 #38838465 未加载
henning超过 1 年前
Like everything in software development, this is just personal preference without any actual evidence, a substitute for actually making software with quantitative quality metrics that users actually care about. Let&#x27;s fiddle with our commit messages, PR formats, code formatting, etc. etc. etc. instead of addressing the fact that our website has 6 different fonts and makes 30 HTTP requests to show a few hundred bytes of text.
评论 #38832839 未加载
评论 #38836575 未加载
knorker超过 1 年前
This seems super subjective, while being written as if it&#x27;s not.<p>I find this way WAY harder to read&#x2F;scan, and very much prefer Google&#x27;s standard: <a href="https:&#x2F;&#x2F;google.github.io&#x2F;eng-practices&#x2F;review&#x2F;developer&#x2F;cl-descriptions.html" rel="nofollow">https:&#x2F;&#x2F;google.github.io&#x2F;eng-practices&#x2F;review&#x2F;developer&#x2F;cl-d...</a>
评论 #38836558 未加载
评论 #38832391 未加载
Salgat超过 1 年前
In my experience consistency is more important than any specific style of commit messages. Similar to style guides for code; there&#x27;s plenty of ways to approach it, but the real value is the consistency in how things are written across all developers.
vitus超过 1 年前
&gt; The second style likely feels foreign, and possibly uncomfortable. It&#x27;s passive voice and present tense — all the things that we aren&#x27;t supposed to make our commit messages.<p>Nitpick: it&#x27;s passive voice and <i>indicative mood</i> (and sometimes subjunctive) -- there&#x27;s nothing wrong with present tense. &quot;Fix typo&quot; is active voice, present tense, and imperative mood. (The Rails commits that dip into past tense bother me slightly, but whatever.)<p>Broadly, I have a few opinions on commit messages. The style doesn&#x27;t really matter as much to me, although I&#x27;m a relatively strong adherent to &quot;one-line summary, followed by paragraph(s) of additional context&quot; (as is standard in the Linux kernel, and supposed best practice at Google even if it isn&#x27;t universal by a long shot).<p>One is that the commit message should be useful for anchoring a search for potentially relevant changes, and for providing broader context re: why the change was made.<p>At the same time, I waffle between putting more description in the commit message, versus just commenting the code (or making the code clearer).<p>The last is more pragmatic: when I&#x27;m searching for a specific change, I&#x27;m often looking at the history of a particular file (blame or otherwise). I can quickly filter out all the &quot;fix typo&quot; messages or &quot;[LSC]&quot; (large-scale change, term used at Google for various company-wide code health refactors). Or if I&#x27;m trying to figure out which change introduced a bug, I&#x27;ll probably bisect it one way or another (I often try to short-circuit that bisection toward the end to save the last few iterations). Either way, I don&#x27;t actually spend that much time reading through commit messages until I&#x27;ve identified a potentially problematic change.
评论 #38838427 未加载
评论 #38832758 未加载
评论 #38835688 未加载
egnehots超过 1 年前
there are pros and cons to both verb-first and subject-first commit styles.<p>verb-first commits can be organised in a few categories. since they are few commit verbs (fix, add, refact..), always use the same verb prefix for bug, features messages and you will have nice categories to scan&#x2F;filter:<p>- add feature<p>- fix bug<p>- refactor logic<p>On the other hand, subject-first indeed put the important part first and let you <i>search</i> for a term:<p>- Instance configure template method called from constructor<p>- Store&#x27;s project method is an alias for fetch<p>- Title is changed<p>Depending on the use case, are you often searching for something? or would you like to highligh the nb of bugs&#x2F;features in the last release?, one style is better suited than the other.<p>For important changes, I like the linux kernel style: oneline summary, details (problem, impact, solution..)<p><a href="https:&#x2F;&#x2F;docs.kernel.org&#x2F;process&#x2F;submitting-patches.html" rel="nofollow">https:&#x2F;&#x2F;docs.kernel.org&#x2F;process&#x2F;submitting-patches.html</a>
TacticalCoder超过 1 年前
I like to be able to read the commit line following the sentence: <i>&quot;This commit shall ...&quot;</i>.<p>For example from TFA:<p><i>&quot;Fix code example in the field_name method&quot;</i><p>gives:<p><i>&quot;This commit shall fix code example in the field_name method&quot;</i>.<p>OK, cool, I may or may not merge it, pull it, whatever-it. But I know what it&#x27;ll do should I use it.<p>Now from what TFA recommends:<p><i>&quot;Default reader batch size is 1000&quot;</i><p>Means nothing. Tells nothing. Is 1000 good or bad? No clue. Is it causing a bug? A performance issue? Was it 1000 before the commit or after applying it? Zero information.<p>I&#x27;ll pass and keep using the &quot;best practice&quot;.<p>Using the best practices the commit would read:<p><i>&quot;Change default reader batch size to 500&quot;</i> or <i>&quot;Change default reader batch size to 1000&quot;</i> or maybe <i>&quot;Add default reader batch size&quot;</i> (btw the commit line in TFA is so bad that I&#x27;m not sure at all it&#x27;s 500 or 1000 or something else I should put here to make my point).<p>The &quot;best practices&quot; aren&#x27;t a bias. They&#x27;re the result of people thinking long and hard as to how to make commit lines as clear as possible.<p>I look at how multi-million lines codebase like Linux or Emacs are doing it and use that as the authority. If it works well enough for these projects, it works well enough for smaller projects.
评论 #38844773 未加载
laerus超过 1 年前
After started using conventional commits [1] for my messages the style of Subject-First commit messages comes almost naturally.<p>[1] <a href="https:&#x2F;&#x2F;www.conventionalcommits.org&#x2F;en&#x2F;v1.0.0&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.conventionalcommits.org&#x2F;en&#x2F;v1.0.0&#x2F;</a>
IshKebab超过 1 年前
I prefer the first style. It reads way less weirdly. I spend way more time <i>reading</i> commit messages than &quot;manually searching&quot; by scanning them. I either arrive at the commit from git blame, or I use this really cool feature of computers called &quot;ctrl-F&quot;.
graypegg超过 1 年前
Past commit messages have 2 uses to me.<p>- Blame view, where I usually want to know the ticket number so I can track down a story which has the business rules the dev was implementing.<p>- Bisect, where I want to know if this works or not without having to do a test run every time.<p>This format is alright I guess, but the best thing you can do honestly is just<p>TICKET: [done&#x2F;works but wip&#x2F;does not work] [describe what you’re thinking]<p>AB-1234: does not work, trying to rewrite this controller to remove all the duplication, &#x2F;api removed temporarily<p>To me, that doesn’t have to be set in stone. No one likes working with a commit message stickler when standardized formats are only useful ~20 times a year to save 10 minutes each. (In my experience)
ikari_pl超过 1 年前
Error messages. Get to the meat of it in the first 3 words, there&#x27;s a high chance that&#x27;s the only part that will get read, or even displayed. It must be the most meaningful part of the error message.
cmgriffing超过 1 年前
I find commit messages are more useful when we consider machines to be primary the consumers of them.<p>Using conventional commit style messages allow us to generate changelogs and modify our semver versions automatically. Generating changelogs by hand is extremely tedious. Modifying semver by hand leads to caring too much about the number.<p>Like others have pointed out, the context and &quot;why&quot; can easily be tracked by linking out to the ticket&#x2F;task that the work is associated with.
评论 #38842693 未加载
alberth超过 1 年前
I go the other extreme and do below as commit messages.<p><a href="https:&#x2F;&#x2F;keepachangelog.com" rel="nofollow">https:&#x2F;&#x2F;keepachangelog.com</a><p>Makes creating change logs super easy &amp; clear.<p>Which is prefacing each commit with either:<p><pre><code> ADDED for new features. CHANGED for changes in existing functionality. DEPRECATED for soon-to-be removed features. REMOVED for now removed features. FIXED for any bug fixes. SECURITY in case of vulnerabilities.</code></pre>
评论 #38838524 未加载
reactordev超过 1 年前
I’m against any style or enforcement of style of commit messages that breaks <i>changelog</i><p>I use git log history for changelogs with a little dressing for markdown. I could pull this from Jira but it’s worse. Stories aren’t changes.<p>So I understand that some folks use git log for history and care about their code style so much as to enforce commit message stylecop, it’s overkill in my world and would only cause you to have to amend your commit or write a new message on squash.
vlovich123超过 1 年前
The problem with the experiment is that when I’m scanning, typically I’m never scanning and then getting tested on the contents after the fact. It actually took me longer to spot any mention of store in the second example after being told what I was looking for than it did for me to find field_name after being told to look for it. YMMV.
teo_zero超过 1 年前
The rationale of subject-first is clear. But what about the other rules: correct instead of fix, rather than instead of rename... They seem pretty arbitrary to me.
评论 #38836516 未加载
asylteltine超过 1 年前
This doesn’t work with conventional commits which is flat out awesome. But I will try mixing both because I like the idea
gavinhoward超过 1 年前
Strong disagree.<p>Commits are actions and should place actions first.<p>If you need to find a specific item, that is what `git log --grep` is for.
评论 #38836534 未加载
Groxx超过 1 年前
Ehhh... maybe. One implicit trade-off here is how low detail the second set is, and that&#x27;ll happen any time you force a structure - mandated structure takes more space on average, sometimes significantly more. Passive voice wastes a lot of space too (in English anyway).<p>Personally I think this is better solved by a changelog doc (which you can wordsmith <i>for outsiders</i>, which is an entirely different target than internal developers) and `git blame` (I never <i>browse all of history</i> to find changes to a method, just blame it for the latest or `git log -p -L` to check a series of changes to a file&#x2F;func&#x2F;etc).
atoav超过 1 年前
Bottom line first. I like it.
sbellware超过 1 年前
Some additional context on this:<p>- There are additional organizational and process mechanics in-play that are out-of-scope for just a write-up on commit messages<p>- The team is made up of around 15 people supporting around 400 repos and about 8 live products<p>- The team DOES NOT use pull requests. Contributors are expected to be socially capable and fully engaged in the inter-personal, realtime communication that supports high-performance, low-handoff work.<p>- The ticketing system is NOT the primary means of communication between team members. It&#x27;s merely a catalog of work items with only high-level supporting notes. A work item, as the old saying goes, is a &quot;placeholder for a conversation&quot;, rather than a work order that can be executed upon by a contributor operating in isolation.<p>- The original author is describing an exceptional software product organization. He&#x27;s not debating the merits of various subjective perspectives on what kind of personal flair might drive the content of commit messages. Instead, he&#x27;s describing one small piece of a methodology that explicitly discourages personal flair and explicitly encourages (and provides supports for) direct communication, and rigorous attention to the team&#x27;s well-considered, proven, and communicated norms.<p>- Contributors on the team are expected to maintain their own work logs in the spirit of engineer&#x27;s logs from engineering industries. If the &quot;why&quot; of a change is important, it will be recorded in the work log. Senior technical leaders (at a minimum) keep up with the individual work logs looking for hazards and maintaining an understanding of the learning that&#x27;s taking place in the team.<p>- Contributors on the team are expected to maintain equipment logs for the components that they&#x27;re making changes to. This isn&#x27;t the same thing as a SCM log, as an SCM log is for the SCM, not the product under development.<p>- The reason that the &quot;subject-first&quot; approach is used is to get contributors to talk specifically to the impacts made to the software itself, rather than talk about themselves and their labors. It&#x27;s about training developers (and designers, and operators, etc) to be more objective about the work they do, and to communicate it in an objective way. Mentions of &quot;changed&quot;, &quot;fixed&quot;, etc, are records from the perspective of the worker, not the product. When scanning the list of changes made to a work product, the team members are primarily interested in the impacts to that piece of equipment first and foremost. The work product change logs are voiced in terms of the work product, and not the worker. Again, the reflections, learning, questions, observations, etc, of the humans involved in the work go into the human&#x27;s own logs, and are supported by the person-to-person processes that are beyond the scope of the article on commit messages.<p>- These 15 people with their 400 repos and 8 live products was winning industry awards within a couple months of go-live within the first year of the team&#x27;s charter. There&#x27;s nothing average about the team, the product, and the methods in-play. The commit messages are just one detail of the finely-honed process and culture that were intentionally designed, socialized, and painstakingly-supported to achieve its objectives.<p>- The author of the article is describing one facet of an overall product development system for a high-performance software organization. He&#x27;s not trying to spark a dialog about the myriad opinions of how commit messages are written across the breadth of software development within processes and cultures that may not go much beyond the cross-referencing of items between ticketing systems with an SCM system, which is arguably a higher-ceremony approach from an artifacts perspective, but also a &quot;bare minimum&quot; from a process and culture perspective.<p>It&#x27;s not entirely pertinent, but just in case there&#x27;s some question as to whether this work is being done in a business of some scale or other at some particular time or other in a business&#x27;s lifecycle that accounts for how the development system works, and whether it&#x27;s a special case: the business context of team&#x27;s work is a $1B multi-national with about 2,000 employees working in the regulatory side of corporate law, finance, and venture capital.<p>The business context isn&#x27;t the enabling factor or the deciding factor. The product development system in-effect is the key factor, and it was shaped explicitly for its outcomes irrespective of the business context. The development system has been used at various companies up-and-down the axis of business scale and scope.<p>The single greatest contributing factor of the team and its work is that they carry very little technical debt, and the methodology required to work this way touches every molecule of process, organization, and culture. It would not be recognizable from the perspective of typical mid-curve software development, and it would not be understood by examining any single process element in isolation.
评论 #38862019 未加载
评论 #38841335 未加载
torton超过 1 年前
Meh, as in this doesn’t feel like it really matters. Like other commenters, there are exceptionally few situations when I find myself just reading the commit log, so the claimed psychological advantage appears moot in the context of the common&#x2F;standard software development process (which is very much not what author’s team does, so I acknowledge this approach brings specific measurable advantages for them).<p>When I do need to read the commit log, it’s typically for a third party component and I look for broad categories I need to pay attention to (security fix? Behaviour change?) — this aligns well with the conventional commits standard and well managed release notes. But, to not have to read commit logs, we also do the rest of the conventional software development workflow (PRs, team meetings, etc) that serves to build the awareness of what’s being done.
isratjahan超过 1 年前
I like the first concept.
tahnyall超过 1 年前
I prefer the first version, I didn&#x27;t find the second version to be more &quot;scannable&quot; and it seems to me to be more esoteric requiring study to realize what was recorded. The first version is clear, each commit makes sense and is what I&#x27;d be grepping for when trying to find a commit.
jes5199超过 1 年前
commit messages are a code smell. If you need to commit code, then you’ve already made a mistake
turtleyacht超过 1 年前
Verb-first is <i>already</i> the subject. We fill in the latter portion of a sentence that begins (in our head), &quot;When merged, this commit will...&quot;