How to Standardise Your Git Commits with GitHub Copilot

VS Code’s Copilot-powered commit message generator is a powerful tool. In this post, I’ll walk through how to enhance its output to better reflect your team’s conventions and make your commits more consistent.

The commit message before

I have just added a new Unit Test to my Go project and select the “Generate Commit Messages with Copilot” button, shown within the red border

which produces the following commit message

Add unit test for HTTP /mcp/time endpoint to validate JSON response

While it’s a good starting point, the message may lack the detail or structure required by your commit standards. This remainder of this post will show you how to refine it.

Changes to settings.json

At the time of this post it is not possible to add this feature via the settings menu and instead it requires changes to the settings.json file. This file can be accessed by bringing up the Command Palette, on Windows via Ctrl + Shift + P or Shift + Cmd + P on macOS and searching for “Open User Settings (JSON)” Once located, add the following

"github.copilot.chat.commitMessageGeneration.instructions": [
        {            
            "text": ""
        }
],

To tailor the output, define your commit requirements in the text field. See the example below for an example.

"github.copilot.chat.commitMessageGeneration.instructions": [
        {            
            "text": "Add one line summary followed by two sections with the following headings: 'Changes' and 'Reason for Changes'. In the 'Changes' section, list the changes made in the code. In the 'Reason for Changes' section, explain why these changes were made. Limit each line to 80 characters. Use markdown formatting."
        }
],

With this change to the settings.json file saved, the commit messages generated from now will take the format of one line summary, followed by two sections. The first Changes and the second Reason along with a breakdown of what should appear in each. The last two sentences detail the length of each line and the formatting required.

The commit message after

The commit message produced when selecting the “Generate Commit Messages with Copilot” button is now

Add unit test for HTTP /mcp/time endpoint

## Changes
- Implemented TestHTTPTimeEndpoint to test the /mcp/time endpoint.
- Mocked getTimeFromMCP to return a predefined value for testing.
- Added handling for HTTP POST requests and JSON decoding.

## Reason for Changes
These changes were made to ensure the /mcp/time endpoint 
returns the correct JSON response for valid requests, 
enhancing overall test coverage and reliability of the code.

Acknowledgments

The genesis of this post comes from the superb talk by Rob Conery at NDC London 2025. Thanks Rob for doing what you do. It is appreciated.

Special thanks also go to David Wilson for his post on the same subject.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.