2 min read
⚒️ Structuring commits with a plan

🤔 Why do we need to think about it?

Drafting well-structured commits is crucial for smooth collaboration, efficient code reviews, and maintaining a clean project history. Thoughtful commits help everyone involved in the development process achieve their goals more easily.

To achieve goals -

  • As a dev:

    • Productive: Get my code merged and pushed to production quickly
    • Ease: Avoid the hassle of rebasing, sending reminders, and replying to comments
    • Plan B: Make it easy to remove or update changes if needed
  • As a code reviewer:

    • Ease: Well-structured commits make code reviews faster and more intuitive
      • Easy to follow
      • Commits are just the right size for review
  • As other dev:

    • Ability to cherry-pick teammates’ changes with confidence

⛳ How can the goals be achieved?

Think like the professor from Money Heist—plan every move!

  1. Have absolute 100% clarity on what all code changes you are going to make for -
    1. Feature
    2. Tech Debt Task
    3. Bugfix
  2. Identify your audience (code-reviewers) well and have some empathy towards them.
  3. Have a plan in mind for all the commits that you are going to create. Things to consider -
    1. Think your commits as building blocks
    2. Push batches of your commits
      1. Commit sizes
      2. Intuitive enough
    3. Minimise the chances of rebasing

Pro Tip: Get your simpler piece of code merged first

💡 Good practices

  • Avoid generic commit messages (Good article to read). For example -
    • Remove lang : ❌
    • Remove unwanted lang params sent in Suggest FAQs API : ✅
  • Use commit description more often
  • Provide links to references wherever needed
  • Identify SMEs for code reviews to get better guidance