commitgpt
Automatically generate commit messages using ChatGPT.

How to use?
npx commitgpt
or use -c
for conventional commits format.
npx commitgpt -c
Getting Your OpenAI API Key and Setting the Environment Variable
- Sign up for an OpenAI account and log in to the OpenAI dashboard: https://beta.openai.com/signup
- Generate a new API key by clicking on the "API Keys" tab and then clicking on the "Create API Key" button.
- Copy the API key to your clipboard.
- Open a terminal or command prompt and set the environment variable with the API key using the following command (replace "YOUR_API_KEY" with the actual API key you copied in step 3):
export OPENAI_API_KEY="YOUR_API_KEY"
- Verify that the environment variable has been set correctly by running the following command:
echo $OPENAI_API_KEY
This should print the value of the OPENAI_API_KEY
environment variable, which should be the API key you set in step 4.
Note: The steps to set environment variables may differ based on your operating system. For more information, you can refer to the documentation for your specific operating system.
How it works
- Runs
git diff --cached
- Sends the diff to ChatGPT and asks it to suggest commit messages
- Shows suggestions to the user
Credits
Some code and approaches were inspired by the awesome projects below:
Do you need API docs? Check out Redocly.