I've written mine up as I've noticed I was repeating myself a bit once my opinions stabilized.<p>See <a href="https://jiby.tech/post/my-git-worfklow/" rel="nofollow">https://jiby.tech/post/my-git-worfklow/</a>
I'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 "lol" and get the same result. What I learned from this is that you don't need to split commits, just commit everything at once and add a "good enough" message. E.g. if you're working on a provider just use "Updated provider"
I'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'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't bring conventions in where a team doesn'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.
My advice is never use conventions for personal/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'm a big proponent of slimmed down version of Conventional Commits' standard. At our startup we would only really use these types: fix/feat/chore/docs/refactor/revert/ci/test.<p>Something simple like:<p>fix(ControlPanel): popover animation no longer causes layout shifts<p>is perfect
The only "convention" that exists is the Conventional Commits' one. It is sensible and compatible with some tools. As long as you write "fix:", "feat:" or "chore:" you'll be fine.<p>Don't overthink it though, it's a thing that is used in some open-source projects and companies. As long as you follow the rules of the project, you'll be fine. Same for the coding style and format, do like everyone else.
Doesn't matter much. What works for me is it's easily skimmable. Rather than say "fix the command widget", it's better to say "command widget fixed". Because if you do verbs, most of your commits will start with "fixed" and stuff and won'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're likely to find commits/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.
The official documentation contains some guidelines and the reasoning behind them:<p><a href="https://git-scm.com/book/ms/v2/Distributed-Git-Contributing-to-a-Project" rel="nofollow">https://git-scm.com/book/ms/v2/Distributed-Git-Contributing-...</a><p><a href="https://git-scm.com/docs/SubmittingPatches#describe-changes" rel="nofollow">https://git-scm.com/docs/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://www.kernel.org/doc/html/latest/process/submitting-patches.html#describe-your-changes" rel="nofollow">https://www.kernel.org/doc/html/latest/process/submitting-pa...</a><p><a href="https://go.dev/doc/contribute#commit_messages" rel="nofollow">https://go.dev/doc/contribute#commit_messages</a>
On some hobby projects I just do a "git add ./*" and set an exquisite commit message along the lines of<p><pre><code> > sync
> blah
> i haven't committed this since a week, so let's do this now
> fix that bug, and 15 other things
</code></pre>
At work, and when I push some OSS code, I do as the Romans do.
For my projects I just use "Temp" and "Works". 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's a necessity to find a commit, I just blame or log with files. But there's usually no necessity, cause I prefer to move forward rather than digging the past.<p>Before anyone screams, I don't expect you to browse my projects, even when they are public or shared. Writing this because it's one of the practical ways. I know you don't like it and would fire me asap even for <i>my</i> project commits, yeah dream about it.
My company has a terrible commit message culture. Half of the commits begin with "in which our hero..." - you can imagine how insanely irritating it is to find relevant changes in logs...
For branch commits, anything (no profanity lol!)<p>For merge commits <ticket number> - <simple description><p>An "and" or long description hints it needs to be broke up
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/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.
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/lab issue #.<p>line 2: blank<p>line 3+: long description, paragraphs, details, context for decisions made, rambling
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/technical details<p>4. (optionally) tests or reproduction scenario