Skip to content

Command-line tool to generate conventional Git commit messages from staged changes using GPT. Built with Python and OpenAI API.

License

Notifications You must be signed in to change notification settings

WoongheeLee/git-commit-message-generator

Repository files navigation

Git Commit Message Generator

README (English) | README (한국어)

Generate concise, conventional commit messages using GPT, directly from your staged git diff.

Powered by OpenAI API and built with Python 3.12. Supports any language supported by GPT (e.g., English, Korean, French, etc.)


Features

  • Auto-generate commit messages using LLM
  • Supports Conventional Commit format
  • Multilingual support (language is GPT-dependent, use --language )
  • PyInstaller-compatible for single-file binary distribution

Requirements

If using source code:

pip install -r requirements.txt

Developed in a Python 3.12 environment. Recommended to use Conda:

conda create -n commit-message python=3.12


Usage (from source)

# Generate and apply commit message
python main.py

# Specify language
python main.py --language english

Setup API Key

OpenAI API key is required. Create the following file in your home directory:

~/.api_keys/openai.json
{
  "api_key": "your-openai-api-key-here"
}

Prompt Template

You can customize the commit format via:

prompt_template.yml

It defines the Conventional Commit format and supported types (e.g., feat, fix, docs...).


Build Standalone Executable (Optional)

PyInstaller is used to create a .exe:

pyinstaller --onefile --add-data "prompt_template.yml;." main.py
  • Executable is saved in dist/main.exe
  • Supports Windows (tested)

Example Output

🤖 Generating commit message in english...

✅ Generated commit message:

feat: add CLI option to specify commit message language

Would you like to commit with this message? [Y/n]:

License

MIT License


Contributing

Gladly welcoming contributors!
Feel free to fork, improve, and send a pull request.

About

Command-line tool to generate conventional Git commit messages from staged changes using GPT. Built with Python and OpenAI API.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published