This extension integrates with Visual Studio to generate meaningful Git commit messages using the OpenAI API. It retrieves your current Git changes, sends them to the OpenAI model, and copies the suggested commit message to your clipboard.
- Automatically detect the current Git repository changes.
- Generate a commit message using OpenAI.
- Display and copy the generated commit message to your clipboard for immediate use.
- Minimal setup required—just ensure you have a valid OPENAI_API_KEY environment variable.
- Visual Studio 2022 or later.
- A valid OPENAI_API_KEY set as an environment variable on your machine. The extension uses this key to authenticate with the OpenAI API.
-
Clone this repository and open the solution in Visual Studio.
-
Set OPENAI_API_KEY as an environment variable. On Windows, you can set it using:
$env:OPENAI_API_KEY="sk-..."
-
Build and run the extension in the Visual Studio Experimental Instance.
-
Open a solution with a Git repository.
-
Make some changes in your repository.
-
Generate a commit message by navigating to:
Extensions > GPT Commit Generator > Generate Commit Message
-
View and copy the generated commit message, which will also be automatically copied to your clipboard.
-
Paste the commit message into your Git commit command line or the Visual Studio Git Changes panel.
- Change the model: The extension currently targets the
gpt-4o-mini
model. You can modify the model name in theGenerateCommitMessageAsync
method. - Modify the prompt: You can alter the prompt or system role instructions as needed to better suit your commit message preferences.
- Verify that your solution folder is under Git source control.
- Confirm that your OPENAI_API_KEY is valid.
- Ensure that you have pending Git changes to generate a meaningful message.
- Verify that the STA thread dispatch logic is functioning correctly to avoid clipboard access issues.