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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Ask HN: What commit message conventions do you follow?

18 点作者 rishikeshs3 个月前
I'm new to the world of programming and came to know about commit conventions. Just wanted to know what conventions do you use.

21 条评论

FrenchyJiby3 个月前
I&#x27;ve written mine up as I&#x27;ve noticed I was repeating myself a bit once my opinions stabilized.<p>See <a href="https:&#x2F;&#x2F;jiby.tech&#x2F;post&#x2F;my-git-worfklow&#x2F;" rel="nofollow">https:&#x2F;&#x2F;jiby.tech&#x2F;post&#x2F;my-git-worfklow&#x2F;</a>
评论 #43063240 未加载
评论 #43062621 未加载
评论 #43063346 未加载
ramon1563 个月前
I&#x27;ve noticed that I split commits and make very verbose but clear messages for each commit, only to never use this afterwards.<p>Meanwhile my coworkers just commit with &quot;lol&quot; and get the same result. What I learned from this is that you don&#x27;t need to split commits, just commit everything at once and add a &quot;good enough&quot; message. E.g. if you&#x27;re working on a provider just use &quot;Updated provider&quot;
评论 #43065375 未加载
codingdave3 个月前
I&#x27;ve never worked on a team that had conventions for both commits and PRs. In general, the goal of such things is to help trace work across multiple systems, and for future research trying to track down old changes. All the places I&#x27;ve worked or consulted, they do that at the PR level, not the commit level. So PRs will start with a ticket #, commits are freeform.<p>That being said, some places do have commit standards. Just ask the team what they do when you start somewhere. Don&#x27;t bring conventions in where a team doesn&#x27;t use them - it just adds noise. If you or the team see how adding conventions can benefit your work, talk about it and make a decision together.
评论 #43061751 未加载
Tinos3 个月前
My advice is never use conventions for personal&#x2F;solo projects - they do not matter.<p>When it comes to working in teams I actually do recommend them because during a code review you can - at a glance - read what each commit has done so you can familiarise yourself with the steps the developer took to reach the state in the PR.<p>For small teams I&#x27;m a big proponent of slimmed down version of Conventional Commits&#x27; standard. At our startup we would only really use these types: fix&#x2F;feat&#x2F;chore&#x2F;docs&#x2F;refactor&#x2F;revert&#x2F;ci&#x2F;test.<p>Something simple like:<p>fix(ControlPanel): popover animation no longer causes layout shifts<p>is perfect
评论 #43061955 未加载
评论 #43060743 未加载
JTyQZSnP3cQGa8B3 个月前
The only &quot;convention&quot; that exists is the Conventional Commits&#x27; one. It is sensible and compatible with some tools. As long as you write &quot;fix:&quot;, &quot;feat:&quot; or &quot;chore:&quot; you&#x27;ll be fine.<p>Don&#x27;t overthink it though, it&#x27;s a thing that is used in some open-source projects and companies. As long as you follow the rules of the project, you&#x27;ll be fine. Same for the coding style and format, do like everyone else.
评论 #43060087 未加载
muzani3 个月前
Doesn&#x27;t matter much. What works for me is it&#x27;s easily skimmable. Rather than say &quot;fix the command widget&quot;, it&#x27;s better to say &quot;command widget fixed&quot;. Because if you do verbs, most of your commits will start with &quot;fixed&quot; and stuff and won&#x27;t be helpful when people actually try to read it.<p>Some people do require to do the whole fix:, chore:, docs:, refactor:, but I find this is more as some quality control tool rather than a documentation tool.<p>Ours is integrated heavily with Jira, so using the ticket number helps the most. We&#x27;re likely to find commits&#x2F;PRs from tickets, or jump to the ticket for the context of the commit. The other entry point is looking at git blame on an IDE, especially a funky looking line of code like `if (nonsense logic)` is causing a bug regression. When this happens, I want the ticket. I can immediately just paste the ticket number into Jira.<p>As always, different styles are suited to different cultures. Read everything here for ideas, but pick one that fits your culture the best.
dpifke3 个月前
The official documentation contains some guidelines and the reasoning behind them:<p><a href="https:&#x2F;&#x2F;git-scm.com&#x2F;book&#x2F;ms&#x2F;v2&#x2F;Distributed-Git-Contributing-to-a-Project" rel="nofollow">https:&#x2F;&#x2F;git-scm.com&#x2F;book&#x2F;ms&#x2F;v2&#x2F;Distributed-Git-Contributing-...</a><p><a href="https:&#x2F;&#x2F;git-scm.com&#x2F;docs&#x2F;SubmittingPatches#describe-changes" rel="nofollow">https:&#x2F;&#x2F;git-scm.com&#x2F;docs&#x2F;SubmittingPatches#describe-changes</a><p>For examples of projects that do this very well, I usually point people to the Linux kernel (for which Git was invented) and Go.<p><a href="https:&#x2F;&#x2F;www.kernel.org&#x2F;doc&#x2F;html&#x2F;latest&#x2F;process&#x2F;submitting-patches.html#describe-your-changes" rel="nofollow">https:&#x2F;&#x2F;www.kernel.org&#x2F;doc&#x2F;html&#x2F;latest&#x2F;process&#x2F;submitting-pa...</a><p><a href="https:&#x2F;&#x2F;go.dev&#x2F;doc&#x2F;contribute#commit_messages" rel="nofollow">https:&#x2F;&#x2F;go.dev&#x2F;doc&#x2F;contribute#commit_messages</a>
not_your_vase3 个月前
On some hobby projects I just do a &quot;git add .&#x2F;*&quot; and set an exquisite commit message along the lines of<p><pre><code> &gt; sync &gt; blah &gt; i haven&#x27;t committed this since a week, so let&#x27;s do this now &gt; fix that bug, and 15 other things </code></pre> At work, and when I push some OSS code, I do as the Romans do.
评论 #43061075 未加载
评论 #43063786 未加载
wruza3 个月前
For my projects I just use &quot;Temp&quot; and &quot;Works&quot;. Sometimes a couple-words summary, which works as a temporary anchor for diffs. <i>Never</i> found myself reading through old commit messages to grasp something, in any vcs (used cvs, svn, git). If there&#x27;s a necessity to find a commit, I just blame or log with files. But there&#x27;s usually no necessity, cause I prefer to move forward rather than digging the past.<p>Before anyone screams, I don&#x27;t expect you to browse my projects, even when they are public or shared. Writing this because it&#x27;s one of the practical ways. I know you don&#x27;t like it and would fire me asap even for <i>my</i> project commits, yeah dream about it.
optikradio3 个月前
My company has a terrible commit message culture. Half of the commits begin with &quot;in which our hero...&quot; - you can imagine how insanely irritating it is to find relevant changes in logs...
评论 #43066196 未加载
aqueueaqueue3 个月前
For branch commits, anything (no profanity lol!)<p>For merge commits &lt;ticket number&gt; - &lt;simple description&gt;<p>An &quot;and&quot; or long description hints it needs to be broke up
clausecker3 个月前
I usually use the one we use in the FreeBSD project, which is to have the subject be of the form &quot;component: action&quot;.
mdavid6263 个月前
Start with a verb in imperative mode, first letter uppercase, no punctuation at the end, for example: “Add about page”.
TheCleric3 个月前
To me it depends on your goals:<p>Do you want to use it to power versioning and CI?<p>Do you want commits traceable to tickets&#x2F;issues<p>Do you want to do merge commits or squashes?<p>Do you want to generate change logs from the commits?<p>Different strategies will benefit different needs.
idontwantthis3 个月前
I put the ticket number first, that way I always know which commits are mine if I do a rebase. I don&#x27;t know why everyone doesn&#x27;t do this.
chistev3 个月前
I describe in past tense what I just did.<p>For example -<p>&quot; uuid added to the test to make the newly created mailbox different each time &quot;
foobarbaz333 个月前
line 1: short description. fit on 1 line. put effort into making it as short as possible while still giving the gist of what was done. maybe a github&#x2F;lab issue #.<p>line 2: blank<p>line 3+: long description, paragraphs, details, context for decisions made, rambling
iExploder3 个月前
applicable for feature or bugfix:<p>1. describe how things work (or not work) currently<p>2. proposed solution to the problem this commit attempts<p>3. more implementation&#x2F;technical details<p>4. (optionally) tests or reproduction scenario
nurettin3 个月前
For juniors, whatever gets you yelled at less. For seniors, whatever you wouldn&#x27;t yell at. In any case there will be yelling.
评论 #43073739 未加载
trcarney3 个月前
&quot;fixed some stuff&quot;
dieselgate3 个月前
“Why” not “what”