How I write Git commit messages
Crafting Better Git Commit Messages with AI 🚀
Hey fellow developers! Today, I want to share something that’s been a game-changer in my daily workflow - how I craft meaningful Git commit messages using AI, without relying on GitHub Copilot.
Quick Method in Cursor
Listen! 🎯 While writing this post, I stumbled upon this quick way to generate commit messages:
- Open Cursor’s Source Control panel (look for the branch/Y-shaped icon in the sidebar)
- Find the commit message input field
- Click the AI-generated commit message button (it looks like a star ⭐)
My Personal Method: Using Cursor Chat
But here’s how I personally prefer to do it:
- 📝 Open Cursor’s Chat
- 🔍 Ensure no file is in the context
- ⚡️ Type
@PR
and hit Enter (this adds @PR (Diff with Main Branch) to the context) - 💬 Use this magic prompt:
You are an engineer who wants to commit changes to the remote codebase. Your job is it to provide a short commit message about the recent changes as a one-liner.
- ✨ Hit Enter and voilà - perfect commit messages every time!
Now that I think about it, I could probably create a Cursor extension to automate this whole process with a single keystroke. Maybe that’ll be my next project!
And that’s it! While both methods use AI to generate commit messages, there’s an interesting difference: my personal method always creates a concise one-liner, while the quick method might generate multi-line messages.
Listen! 💡 I personally prefer the one-liner approach as it keeps my git history clean and scannable. But now you know both methods - try them out and see which style works better for your workflow!
~Sven