Using GitHub Copilot to Generate Conventional Commit Messages in VSCode and IntelliJ IDEA
In this tutorial, you’ll learn how to supercharge your Git workflow by using GitHub Copilot to generate commit messages that follow the Conventional Commits standard—directly inside both VS Code and IntelliJ IDEA. We’ll cover setup, best practices, and tips for both editors, so you can keep your commit history clean, consistent, and meaningful.
Why Conventional Commits?
Conventional Commits provide a simple, human- and machine-readable convention for commit messages. This makes it easier to automate releases, generate changelogs, and understand project history at a glance. With Copilot, you can automate the process and avoid the mental overhead of crafting the perfect message every time.
Using Copilot for Commit Messages in VS Code
GitHub Copilot can suggest commit messages based on your staged changes, making it easy to follow the conventional format. Here’s how to get started:
- Make sure you have the GitHub Copilot extension installed in VS Code.
- Stage your changes in the Source Control panel.
- Click into the commit message input box. You’ll see a sparkle icon (✨).
- Click the icon, and Copilot will analyze your diff and suggest a commit message.
Configure Custom Instructions for Commit Messages in VS Code
To ensure Copilot generates messages in the conventional format, you can set custom instructions in your settings:
"github.copilot.chat.commitMessageGeneration.instructions": [
{ "text": "Use conventional commit format: type(scope): description." },
{ "text": "Use imperative mood: 'Add feature' not 'Added feature'." },
{ "text": "Keep subject line under 50 characters." },
{ "text": "Use types: feat, fix, docs, style, refactor, perf, test, chore, ci." },
{ "text": "Include scope when relevant (e.g., api, ui, auth)." },
{ "text": "For additional details, use a well-structured body section." },
{ "text": "Use bullet points (*) for clarity." }
]
You can also save these instructions in a file for easy sharing with your team. The file
key should point to the filename (e.g., global-git-commit-instructions.md
), not the instruction text itself:
"github.copilot.chat.commitMessageGeneration.instructions": [
{ "file": "path/to/file/global-git-commit-instructions.md" }
]
Then, in your global-git-commit-instructions.md
file, add your actual instructions (one per line or as a markdown list). This tells Copilot to load all instructions from that file.
Using Copilot for Commit Messages in IntelliJ IDEA
IntelliJ IDEA also supports Copilot’s commit message generation, making it easy to keep your workflow consistent across editors.
1. Enable Copilot in IntelliJ IDEA
- Install the GitHub Copilot plugin from the JetBrains Marketplace.
- Open the Commit window after staging your changes.
- You’ll see a Copilot icon or prompt in the commit message area. Click it to generate a suggestion.
Configure Custom Instructions for Commit Messages in IntelliJ IDEA
- Go to Settings > Tools > GitHub Copilot > Custom Instructions.
- Under Git Commit Instructions, set your preferences for commit message style. You can use the same conventional commit guidelines as in VSCode.
If you select Global
, IntelliJ will create a global-git-commit-instructions.md
file and you can add the instructions as desired.
Use conventional commit format: type(scope): description.
Use imperative mode: 'Add feature' not 'Added feature'.
Keep subject line under 50 characters.
Use types: feat, fix, docs, style, refactor, perf, test, chore, ci.
Include scope when relevant (e.g., api, ui, auth).
For additional details, use a well-structured body section.
Use bullet points (`*`) for clarity.
.
Best Practices & Tips
- Review before committing: Copilot’s suggestions are great, but always review and tweak for accuracy and context.
- Use scopes: Add a scope (e.g.,
feat(api): ...
) to clarify what part of the codebase is affected. - Keep it short: Subject lines should be concise and under 50 characters.
- Add details: Use the body section for context, rationale, or bullet points if needed.
- Standardize for teams: Share your commit instructions in your repo to keep everyone aligned.
References
- Conventional Commits
- GitHub Copilot for VS Code
- GitHub Copilot for IntelliJ IDEA
- VS Code Docs: Copilot Commit Messages
- IntelliJ Docs: Copilot Commit Messages
Have you tried feature this yet?
Happy Coding!