Skip to main content

Command Palette

Search for a command to run...

Your Commit Messages Suck ๐Ÿ‘Ž; Here's How to Fix It

Elevate Your Development Workflow with Crystal-Clear Semantic Commit Messages

Published
โ€ข3 min read
Your Commit Messages Suck ๐Ÿ‘Ž; Here's How to Fix It
M

๐Ÿ‘‹ Hey there! I'm Muiz Haruna, a passionate Front-end Developer on a relentless quest to explore the ever-evolving world of web technologies. With a knack for crafting seamless user experiences, I blend my coding prowess with a love for storytelling, serving as both a Front-end Developer and Technical Writer.

๐ŸŒŸ As a Front-end Engineer, I thrive on the challenges of turning innovative designs into functional, pixel-perfect websites. My journey involves constant learning and experimentation with the latest frameworks, libraries, and best practices in the realm of HTML, CSS, and JavaScript.

โœ๏ธ Simultaneously, I indulge my passion for effective communication through technical writing. I document my coding adventures, share insightful tutorials, and demystify complex concepts in the tech space. Join me as I navigate through the exciting landscape of front-end development, armed with both code and words.

๐Ÿš€ Let's embark on this coding journey together, where I'll not only write about my discoveries and lessons learned but also empower you to create stunning web experiences!

Hey there, fellow developers!

Today, let's talk about one of the most overlooked yet crucial aspects of collaborative coding โ€“ commit messages.

We've all been guilty of hasty, unclear commit messages, but fear not! In this article, we'll delve into the world of semantic commit messages and learn how they can significantly improve your development workflow.

The Anatomy of a Semantic Commit Message

A semantic commit message follows a specific structure:

<type>[optional scope]: <description>

[optional body]

[optional footer(s)]

Let's break it down:

<type>: Describes the purpose of the commit. It can be one of the following:

  • feat: Introducing a new feature for the user.

  • fix: Resolving a bug for the user.

  • docs: Documentation changes.

  • style: Code formatting, missing semicolons, etc.

  • refactor: Refactoring production code.

  • test: Adding or refactoring tests.

  • chore: General maintenance tasks.

[optional scope]: Describes the module or component the commit affects.

<description>: Uses imperative, present tense. Clearly states what the commit does.

[optional body]: Provides additional context, if needed. Describes the motivation for the change and contrasts with the previous behavior.

[optional footer(s)]: Contains references to issues and notes on breaking changes.

Example for <type> and <scope>

feat(init): add user authentication

style(web-server): enforce consistent code formatting

chore(config): update dependencies

Examples of semantic commit messages

  1. Adding a New Feature:
feat(user-auth): implement OAuth2 login
  1. Fixing a Bug:
fix(validation): resolve issue with form not validating email input
  1. Documentation Update:
docs(readme): update installation instructions
  1. Code Formatting:
style(codebase): enforce consistent indentation
  1. Refactoring Code:
refactor(api): rename variable for clarity
  1. Adding Tests:
test(auth): add unit tests for login functionality
  1. General Maintenance Task:
chore(dependencies): update package versions

Writing Commit Messages โ€“ Best Practices

  1. Be Clear and Concise: A developer should understand the purpose of your commit by reading the message.

  2. Present Tense: Use imperative, and present tense. For example, "add feature" instead of "added feature."

  3. Provide Context: Include a brief explanation of why the change is necessary.

  4. Reference Issues: If your commit resolves an issue, mention it in the footer using "Closes #issueNumber."

  5. Breaking Changes: Clearly document breaking changes in the footer using the "BREAKING CHANGE:" keyword, along with a description, justification, and migration notes.

Why bother about commit messages

Semantic commit messages bring clarity and structure to your version control history. They make it easier to track changes, understand the project's evolution, and collaborate effectively.

In the end, take the time to craft meaningful commit messages. Your future self and your collaborators will thank you.

Read more here: http://karma-runner.github.io/1.0/dev/git-commit-msg.htmlhttps://www.conventionalcommits.org/en/v1.0.0/

Happy coding! ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿš€

DEVDESIIGNN from Eyes on Tech.