git,

The right way to write Git commit messages

Nov 08, 2022 · 1 min read · Post a comment

I think we’ve all been there writing one or few of the following Git commit messages: test, “new feature Y”, “Changed something”, “asdasd”, “minor update”, etc. You can tell nothing from what was done if you don’t open the commit changes by yourself. So, having a good Git commit message practice should be fundamental implemented as early in the project as possible.

Commit message and commit subject are used interchangeably.

Prerequisites

  • Git

Solution

Focus on writing accurate and comprehensible sentences. There is no one-size-fits-all, although here are some starting points:

  • Begin all commit messages with a capital letter.
  • Do not end the commit subject with a dot.
  • Do not use any punctuations.
  • Use imperative mood.
  • Use present tense.
  • Start the sentence with a type of commit such as: feat, fix, refactor, docs, style, test and so on. Alternately, use a JIRA project + ticket ID for instance: DC-385. Or, combine both: DC-385(docs).

Examples:

feat: Add status page
docs: Add db migration documentation
fix: Registration form do not send emails
refactor: Landing page
DC-387: Include redis library
DC-389(test): Test ci/cd pipeline

In case you got a few more, please share them in the comment section below.

Conclusion

To find more neat Git commands and hacks, simply browse the Git category. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.

git