🤔 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
- Ease: Well-structured commits make code reviews faster and more intuitive
-
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!
- Have absolute 100% clarity on what all code changes you are going to make for -
- Feature
- Tech Debt Task
- Bugfix
- Identify your audience (code-reviewers) well and have some empathy towards them.
- Have a plan in mind for all the commits that you are going to create. Things to consider -
- Think your commits as building blocks
- Push batches of your commits
- Commit sizes
- Intuitive enough
- 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