How to improve your commit messages to collaborate better with your team

Let's learn some of the best practices for writing quality commit messages.

Be specific and clear

Clearly mention what you did in the commit message. If you are fixing a bug, mention the bug number in the commit message. If you are adding a new feature, mention the feature name in the commit message.

git commit -m "fix(#123): Resolve issue with user profiles not rendering"

Provide context

Address 'why' this change has been done,

# Bad - No context
git commit -m "Updated files"


# Good - With context around user profiles
git commit -m "fix(#123): Resolve issue with user profiles not rendering"

Keep it short and use imperative mood

# Bad
git commit -m "I have updated dependency for security"

# Good - have context, short and imperative mood
git commit -m "chore: Update dependencies for better security in user endpoints"

Use emojis (bonus)

I like it when people use emojis in commit messages. It makes it more fun to read. Here are some of the emojis I use in my commit messages.

  • :bug: - When fixing a bug
  • :sparkles: - When adding a new feature
  • :art: - When improving the format/structure of the code
  • :racehorse: - When improving performance
  • :memo: - When writing docs
  • :white_check_mark: - When adding tests
  • :lock: - When dealing with security
  • :arrow_up: - When upgrading dependencies
  • :arrow_down: - When downgrading dependencies
  • :shirt: - When removing linter warnings

Tagging for improving clarity

  • fix - when fixing a bug
  • feat - when adding a new feature
  • chore - when updating build tasks, package manager configs, etc
  • docs - when writing docs
  • style - when formatting code, updating linter configs, etc; no code change
  • refactor - when refactoring code; no feature or bug fix
  • perf - when improving performance
  • test - when adding tests; no feature or bug fix
  • build - when making changes to build scripts, CI configs, etc
  • ci - when making changes to CI configs, etc
  • revert - when reverting changes

What if you want to use multiple tags? You can use [] to add multiple tags.

git commit -m "[feat][#123]: Add new user profile page"

Example commit message,

fix: Resolve issue with login button not redirecting to dashboard
chore: Refactor API calls for improved error handling
style: Adjust button padding and font size for better mobile responsiveness
feat: Introduce user authentication via OAuth 2.0
docs: Clarify usage of config parameters in README
test: Add unit tests for user registration module

Hope you learned something new today. Happy coding and ask me any questions on my Twitter 🚀.

Beginners to ProNode Js

Visual Guide to API Design Best Practices

This visual eBook covers essential best practices for designing robust APIs using REST principles.

This book is ideal for beginners and backend developers seeking to enhance their API design skills. However, it is not suited for those seeking an in-depth exploration of API design. This book is a quick read under 40 slides like scrolling through your instagram feed.

Visual Guide to API Design Best Practices