Commitments to clean commits

By Amr

Learn how to maintain clean commits in your projects for better collaboration and version control efficiency.

Estimated reading time: 2 minutes

Edit on Github

Ah, brave adventurer! You’ve mastered the sacred art of branching and the scroll-writing ritual known as the Pull Request. Now, prepare thyself for the next enchanted trial:


πŸ“ Commit Hygiene & the Magic of Tiny Spells (Chapter 2)

Welcome to the Hall of Git Commit Lore, where great developers are remembered not by the size of their changes, but by the clarity of their messages. Here, we embrace the Tiny Spell Rule: One spell per scroll. One change per commit.


πŸͺ„ The Rule of Atomicity

A wise coder once said: β€œDon’t mix your potions.” Each commit should contain one logical changeβ€”no more, no less. Fixing a bug and tweaking the font? That’s two commits, dear wizard.

🧠 Why care?

  • Easy to track what broke (and who broke it πŸ‘€)

  • Easier reviews, easier rollbacks

  • Clean history = happy time-traveling with git blame


πŸ“¦ Naming Your Spells (a.k.a. Commit Messages)

Commits should read like commands from an ancient book. Short, imperative, and focused.

✨ The Format:

[type]: Brief, powerful description

Optional: Details for fellow wizards.
- Use bullet points
- Reference issues like Fixes #42

πŸ§™β€β™‚οΈ Allowed Spell Types:

  • feat: A dazzling new feature

  • fix: Bug exorcism

  • docs: Documentation enchantments

  • refactor: Code reweaving without changing behavior

  • test: Adding test shields

  • chore: Non-functional but necessary work (e.g., build updates, lint configs)


πŸ§ͺ Example Commit Scrolls

fix: Prevent unicorns from breaking login form

Login page now properly handles magical input.
- Added validation for glitter overflow
- Fixed edge case for rainbow passwords

Fixes #99
feat: Summon dark mode theme toggle

- Adds crescent moon toggle in navbar
- Stores user preference in local storage
chore: Update potion dependencies to latest brew

🧹 Commit Smells (Avoid These Cursed Patterns)

  • ❌ update stuff

  • ❌ more fixes lol

  • ❌ final version for real

  • ❌ temp pls ignore

These are scrolls written in the ancient language of confusion. Burn them.


🎩 Bonus Spell: Use git rebase -i to rewrite messy commit history. Clean your spellbook before publishing it to the world.


Now go forth and cast tiny, purposeful commits that will echo through the halls of version control! 🏰

Ready to open the next dusty tome? We’ll be diving into Changelogs & Documentation, the sacred texts of any thriving code kingdom. Shall we?