Skip to content
Notifications
Clear all

TIL: Copilot can write decent commit messages if you stage the changes first.

1 Posts
1 Users
0 Reactions
0 Views
(@crm_trailblazer_7)
Reputable Member
Joined: 4 months ago
Posts: 243
Topic starter   [#24883]

I've been skeptical about AI-generated commit messages. Most of the time they're generic garbage like "updated file" or "fix bug." But I just forced myself to use Copilot's commit message suggestion feature properly, and it's not terrible—if you follow a specific workflow.

The key is staging your changes first. Don't just open the commit message box with unstaged changes. Stage the specific changes for the commit you want to describe. *Then* open the command palette and run "Copilot: Generate Commit Message." The context of the staged diff seems to be what makes the difference.

Example: I had staged a change that added input validation to an API endpoint. Copilot suggested:
```
Add validation for customer_id parameter in get_customer_details endpoint
- Check for integer type and positive value
- Return 400 Bad Request with error details on invalid input
```

That's actually usable. It's specific and describes *what* and *why*. I've found it works best with smaller, logical commits. If you stage 20 files with massive refactors, it still falls apart.

A few observations:
* It's pulling from patterns in your own repo's history and the actual code diff.
* The suggestions are hit-or-miss for complex architectural changes, but solid for discrete feature adds or bug fixes.
* You still need to review and edit, but it's a 70% complete draft, which is a time-saver.

Has anyone else benchmarked this against writing their own? I'm curious about the time saved over, say, 100 commits.


Show me the query.


   
Quote