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 packages (
pip install -r requirements.txt
). - Create a file at
$XDG_CONFIG_HOME/openaiapirc
with your API keys. - [optional] Add proxy server settings to the config file. Http proxy is supported only.
- [optional] The maximum number of changed lines in a commit. If the number of changed lines is greater than this value, the hook will send the result of git diff --cached --stat, otherwise it will send git diff --cached. The default value is 80.
For example:
[openai]
secret_key = MY_SECRET_KEY
proxy= HTTP_PROXY
max_changed_lines=80
- Install the hook:
git clone https://github.com/jsfs2019/chatgpt_commit_message_hook
cd chatgpt_commit_message_hook
sudo make install
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.