Let ChatGPT write your commit messages.
ChatGPT will provide a suggestion for the commit message.
This is a hook for git that generates commit messages. It uses OpenAI's ChatGPT to generate commit messages.
- Install the OpenAI API package (
pip install openai
). - Create a file at
$XDG_CONFIG_HOME/openaiapirc
with your API keys. For example:
[openai]
secret_key = MY_SECRET_KEY
- Install the hook:
destination="/usr/share/git-core/templates/hooks/prepare-commit-msg"
sudo wget https://raw.githubusercontent.com/tom-doerr/chatgpt_commit_message_hook/main/prepare-commit-msg -O $destination
sudo chmod +x $destination
This will set up the hook for all new repositories.
To add the hook to an existing repository, run git init
.
The hook gets the current commit message, runs ChatGPT to generate a new commit message, and then replaces the current commit message with the generated message.