Generate commit messages with AI (Google Gemini) automatically using `git diff`.
Project description
commitmessagegenerator
Generate objective and technical commit messages with AI (Google Gemini) automatically using your git diff.
📦 Install
pip install commitmessagegenerator
Or, if you're using a venv:
python -m venv venv
source venv/bin/activate # or .\venv\Scripts\activate in Windows
pip install commitmessagegenerator
⚙️ Configuring
commitgen -cf
This opens an interactive configuration menu where you can:
- Set or update your Gemini API key
- Change the AI model
- Configure file staging behavior
Each option can be configured independently, and you can exit at any time without saving changes.
Run this and type you API key to the terminal so the package creates the .env file and automatically adds it to the .gitignore
Or do it manually:
IMPORTANT - BEFORE CREATING THIS FILE ADD '.venv' TO YOUR .gitignore SO YOUR API KEY ISN'T EXPOSED
Create a .env file in the directory where you will run commitgen (usually the root of your Git project):
GEMINI_API_KEY=your-gemini-api-key
AI_MODEL=gemini-2.0-flash
AUTO_ADD_ALL=true
🚀 Usage
With the terminal, inside any Git repository with pending changes, run:
commitgen (-c/-cp)
The command will:
- Read the git diff;
- Send it to the Google Gemini API using your configured model;
- Return a commit message suggestion directly in your terminal.
Available Commands
commitgen- Generate commit message onlycommitgen -c- Generate and commit with the messagecommitgen -cp- Generate, commit, and pushcommitgen -cf- Configure API key, model, and file staging behaviorcommitgen -s- Show current configuration status
Available Models
When configuring with -cf, you can choose from:
- gemini-2.0-flash (default) - Fast and efficient
- gemini-1.5-flash - Good balance of speed and quality
- gemini-1.5-pro - Highest quality, slower
- gemini-2.0-flash-exp - Experimental version
- gemini-2.5-flash - Latest version, fast and efficient
- gemini-2.5-pro - Latest version, highest quality
File Staging Behavior
When configuring with -cf, you can choose how files are staged:
- Auto-add all files (default) - Automatically runs
git add --allbefore generating the commit message - Staged only - Only reads the diff from files you've already staged with
git add
The "staged only" option gives you more control over which changes are included in the commit message.
🧩 Requisites
- Python 3.8 or higher
- Gemini API Key (Google Generative AI, free at: https://aistudio.google.com/app/apikey)
- Initialized Git repository
- Python dependencies (Automatically installed with the package):
GitPythongoogle-generativeaipython-dotenv
📄 License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file commitmessagegenerator-2.2.0.tar.gz.
File metadata
- Download URL: commitmessagegenerator-2.2.0.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd6576ca1e5a70f841d7cc832230274b9abdfc9710783362f25fac30535f2fbb
|
|
| MD5 |
06058b1754eda9576efc256d48383059
|
|
| BLAKE2b-256 |
3bdc60425c2fad3d6cbdcf3e802575d76ad59fcebbc344c99cff3405307fa6a7
|
File details
Details for the file commitmessagegenerator-2.2.0-py3-none-any.whl.
File metadata
- Download URL: commitmessagegenerator-2.2.0-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42b049deba049149370dc095d9df094fcddc25495a43077659c1cb8ef769de15
|
|
| MD5 |
c23201cf7dc518962cc262f776ed2748
|
|
| BLAKE2b-256 |
a6c45a536cfb58a558677272362e1ac89c43a3d25aa6f243b08367cc32735484
|