Improve Git Commit History with CommitLint

𝗧𝗵𝗮𝘁 "𝗪𝗵𝗮𝘁 𝗱𝗶𝗱 𝗜 𝗲𝘃𝗲𝗻 𝗱𝗼 𝗵𝗲𝗿𝗲?" 𝗳𝗲𝗲𝗹𝗶𝗻𝗴 𝘄𝗵𝗲𝗻 𝗹𝗼𝗼𝗸𝗶𝗻𝗴 𝗮𝘁 𝗼𝗹𝗱 𝗰𝗼𝗺𝗺𝗶𝘁𝘀 𝗶𝘀 𝘁𝗵𝗲 𝘄𝗼𝗿𝘀𝘁. 🤦♂️ We’ve all been there: scrolling through a Git history filled with "updates," "fix," or "temp," and even the person who wrote it has no idea what changed. To solve this, I’ve started using a customized CommitLint configuration. No more guessing—just clean, structured, and searchable history. 🚀 𝗪𝗵𝘆 𝘂𝘀𝗲 𝗖𝗼𝗺𝗺𝗶𝘁𝗟𝗶𝗻𝘁? It acts as a gatekeeper for your Git messages. If the commit doesn't follow the rules, it doesn't get in. It forces the team (and my future self) to be intentional. By default, CommitLint is a strict gatekeeper. If your message doesn't follow the type(scope): subject format, it stops the commit entirely. No exceptions. 𝘽𝙪𝙩 𝙄 𝙙𝙞𝙙𝙣'𝙩 𝙨𝙩𝙤𝙥 𝙖𝙩 𝙩𝙝𝙚 𝙙𝙚𝙛𝙖𝙪𝙡𝙩𝙨. 𝙄’𝙫𝙚 𝙖𝙙𝙙𝙚𝙙 𝙘𝙪𝙨𝙩𝙤𝙢𝙞𝙯𝙖𝙩𝙞𝙤𝙣𝙨 𝙩𝙤 𝙛𝙞𝙩 𝙢𝙮 𝙨𝙥𝙚𝙘𝙞𝙛𝙞𝙘 𝙥𝙧𝙤𝙟𝙚𝙘𝙩 𝙣𝙚𝙚𝙙𝙨: ✅ 𝗖𝘂𝘀𝘁𝗼𝗺 𝗧𝘆𝗽𝗲𝘀: Added specific types like perf for performance and build for dependency shifts. ✅ 𝗦𝗰𝗼𝗽𝗲 𝗘𝗻𝗳𝗼𝗿𝗰𝗲𝗺𝗲𝗻𝘁: Forced the use of scopes (like auth, api, or ui) so I know exactly where the change happened at a glance. ✅ 𝗛𝗲𝗮𝗱𝗲𝗿 𝗟𝗲𝗻𝗴𝘁𝗵: Capped headers at 100 characters to keep the Git history readable. 𝗧𝗵𝗲 𝗖𝗹𝗲𝗮𝗻 𝗦𝗲𝘁𝘂𝗽: 𝗡𝗮𝘁𝗶𝘃𝗲 .𝗴𝗶𝘁𝗵𝗼𝗼𝗸𝘀 ⚓ While many developers use the Husky npm package for this, I preferred a more lightweight approach. I’ve used a custom .githooks folder in my project root to manage the hooks directly. This keeps the repo clean and ensures the rules are enforced the moment you hit `git commit`. 𝗧𝗵𝗲 𝗿𝗲𝘀𝘂𝗹𝘁? 𝗔 𝗚𝗶𝘁 𝗵𝗶𝘀𝘁𝗼𝗿𝘆 𝘁𝗵𝗮𝘁 𝗮𝗰𝘁𝘂𝗮𝗹𝗹𝘆 𝘁𝗲𝗹𝗹𝘀 𝗮 𝘀𝘁𝗼𝗿𝘆: feat(auth): add user registration fix(api): resolve pagination issue refactor(payments): simplify checkout logic 𝗪𝗮𝗻𝘁 𝘁𝗼 𝘀𝗲𝗲 𝘁𝗵𝗲 𝗳𝘂𝗹𝗹 𝘀𝗲𝘁𝘂𝗽? 📖 Read about my customization here: https://lnkd.in/dhgWjZvi 🛠️ Grab the config file here (i have commented some lines, to not make it super strict but you can try things): https://lnkd.in/dCM3QHkU Stop treating your commit history like the "wild west." Start building a legacy of clean code! 🛠️✨ Do you prefer a native .githooks approach or do you stick with Husky? Let’s talk below! 👇 #Git #CommitLint #Github #BitBucket #Gitlab #CleanCode #WebDevelopment #ProgrammingTips #SoftwareEngineering #DevTools #OpenSource #Backend #DevOps #Github

  • diagram, text

To view or add a comment, sign in

Explore content categories