GPT-Commit is an Emacs package that automatically generates conventional commit messages using the GPT (Generative Pre-trained Transformer) model from OpenAI.
If you have MELPA configured, you can easily install gpt-commit
from within Emacs by running:
M-x package-install RET gpt-commit RET
To install this package manually, clone this repository and add the following to your .emacs
or init.el
:
(add-to-list 'load-path "/path/to/gpt-commit")
(require 'gpt-commit)
- Set OpenAI API Key: You will need an API key from OpenAI to use the GPT model. Set the key like this:
(setq gpt-commit-openai-key "YOUR_OPENAI_API_KEY")
- Set GPT Model Name (Optional): By default, it uses the
gpt-3.5-turbo
model. If you wish to use a different model, you can set it like this:
(setq gpt-commit-model-name "YOUR_PREFERRED_MODEL_NAME")
- Add Hook: Add the
gpt-commit-message
function to thegit-commit-setup-hook
to automatically generate commit messages when the commit message editor starts:
(require 'gpt-commit)
(add-hook 'git-commit-setup-hook 'gpt-commit-message)
Once you have configured gpt-commit
, it will automatically generate a commit message using the GPT model whenever you perform a Git commit. You can accept the message by saving and closing the editor, or you can modify the message as needed.
Please note that using the OpenAI API might incur costs, and there might be usage limitations. Be aware of the OpenAI pricing and policy before extensive use.
GPT-Commit is licensed under the GNU General Public License v3.0.