VS Code Extension: Auto Commit with GPT
This extension automatically generates Conventional Commit messages for each modified file in your Git repository using OpenAI's API.
Setting Up the OpenAI API Key
Before using the extension, you need to configure your OpenAI API key. Here's how to do it:
Step 1: Obtain Your OpenAI API Key
- Go to OpenAI's platform and sign in or create an account.
- Navigate to the API section and create a new API key.
- Copy the API key for the next steps.
To use the OpenAI API with this extension, you must add the API key to your VS Code settings:
- Open Visual Studio Code.
- Open the Command Palette (
Ctrl+Shift+P or Cmd+Shift+P on macOS).
- Search for
Preferences: Open Settings (JSON) and select it.
- Add the following JSON snippet to your settings file, replacing
"your-openai-api-key" with your actual API key:
{
"extension.openaiApiKey": "your-openai-api-key"
}
- Save the file.
Now, the extension will have access to your OpenAI API key.
Using the Extension
Once the API key is configured, follow these steps to use the extension:
- Open the Command Palette (
Ctrl+Shift+P or Cmd+Shift+P on macOS).
- Type
Auto Commit and select the command from the list.
- The extension will analyze the changes in your Git repository and generate Conventional Commit messages based on the changes.
Make sure you have Git properly configured in your project, as the extension relies on Git to detect changes.
Troubleshooting
API Key Not Set: If the OpenAI API key is not configured, you will see an error like:
OpenAI API key not configured. Add the key in VS Code settings.
Ensure that the key is correctly added in the VS Code settings as described above.