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 šŸš€.

šŸ”„ Limited Time Offer
Coding with AI: Learn to build a SaaS MVP in 10 days

Coding with AI: Learn to build a SaaS MVP in 10 days

Master practical AI development to build and launch your startup MVP in weeks instead of months. Learn to leverage AI tools and APIs effectively.

  • šŸŽÆ Build real MVP: AI-powered SaaS from idea to launch
  • šŸ¤– Integrate ChatGPT, Claude, and other AI APIs efficiently
  • šŸ’° Implement AI features users will pay for
  • āš”ļø AI-assisted coding patterns to ship 10x faster
  • šŸš€ Launch your product in 10 days, not 10 months