1. Home
  2. Setting up GitHub Copilot for Better Commit Messages in VS Code

Setting up GitHub Copilot for Better Commit Messages in VS Code

Setting up GitHub Copilot for Better Commit Messages in VS Code

Setting up GitHub Copilot for Better Commit Messages in VS Code

Look, we've all been there. It's 11 PM, you've just fixed a nasty bug, and you're about to commit with "fix stuff" or "update things". Six months later, you're staring at your git history wondering what the hell you were thinking.

GitHub Copilot Chat can actually help here, but only if you configure it properly. Here's how I set up my VS Code to make Copilot generate proper commit messages following Conventional Commits.

Why I Actually Care About Commit Messages Now

After years of writing garbage commit messages, I finally got convinced when I saw how much easier my life became:

  • Git history becomes readable: git log --oneline actually tells a story
  • Automated versioning: Tools like semantic-release can bump versions automatically
  • No more manual changelogs: Your commit history IS your changelog
  • Code reviews don't suck: Reviewers immediately understand what changed

Opening VS Code Settings

Quick way:

  1. Ctrl+Shift+P → "Preferences: Open Settings (JSON)"
  2. Or just search for settings.json in the Command Palette

Configuring Copilot Commit Instructions

Here's the configuration I use in all my projects:

{
  "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": "Reference issue numbers with # prefix" }
  ]
}

Important: The order matters - Copilot processes these instructions from top to bottom.

Understanding the Commit Types

Here's what each type actually means in practice:

  • feat: New features (feat(auth): add OAuth2 login)
  • fix: Bug fixes (fix(api): handle null response in user endpoint)
  • docs: Documentation changes (docs: update API documentation)
  • style: Code formatting, no logic changes (style: fix indentation)
  • refactor: Code restructuring without new features (refactor(db): extract connection logic)
  • perf: Performance improvements (perf(query): optimize database query)
  • test: Adding/changing tests (test(auth): add unit tests for login)
  • chore: Build system, dependencies (chore: update dependencies)
  • ci: CI/CD changes (ci: add Docker build step)

The type(scope): description format helps you understand what changed at a glance.

How It Works in Practice

  1. Stage your changes in the Source Control view (Ctrl+Shift+G)
  2. Type /generate commit in the commit message field
  3. Copilot generates a message based on your configured rules
  4. Review the message, adjust if needed, commit

Example: After changes to a user API, Copilot generates:

feat(api): add user profile endpoint

- Add GET /api/users/profile route
- Include user preferences in response
- Add authentication middleware

Customizing Further

Want to make it even more specific? Add instructions like:

  • Project-specific scopes: { "text": "Use scopes: frontend, backend, database, config" }
  • Ticket format: { "text": "Append ticket numbers like PROJ-123" }
  • Breaking changes: { "text": "Mark breaking changes with BREAKING CHANGE footer" }

Team-Wide Configuration

Drop this into your repo's .vscode/settings.json and commit it:

{
  "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": "Reference issue numbers with # prefix" }
  ]
}

Now everyone on your team gets consistent commit messages without any nagging.

What I've Learned

After using this setup for a few months:

  • It's not perfect: Sometimes you need to tweak the generated message
  • Context matters: The better your staged changes are organized, the better the messages
  • It gets better: Copilot seems to learn from your corrections over time
  • Team adoption: Once people see good commit messages being generated, they start using it

The Bottom Line

Good commit messages aren't just about being pedantic - they actually make development easier. When you can quickly scan git log and understand what happened, when git bisect gives you meaningful context, and when your automated tools can parse your history properly, you'll wonder why you didn't do this sooner.

Set it up once, get better commit messages forever. That's a pretty good deal.


Check out the Conventional Commits specification if you want to dive deeper into the format.