Commi is an AI-powered tool that automatically generates Git commit messages based on your code changes. It uses Google's Gemini AI to analyze your Git diffs and suggest meaningful, descriptive commit messages. Commi helps save time and ensures your commit history is consistent and descriptive.
- AI-powered commit message generation: Suggest commit messages based on the code changes using Google's Gemini AI.
- Staged changes support: Generate commit messages based on the current staged changes.
- Direct commit: Generate and commit the suggested commit message directly to your repository.
- Clipboard integration: Optionally copy the generated commit message to your clipboard for easy pasting.
To install Commi manually, follow these steps:
-
Clone the repository:
git clone https://github.com/Mahmoud-Emad/commi.git cd commi
-
Install the dependencies:
poetry install
-
Build the executable:
./build.sh # This aslo will move the excutable to `/usr/local/bin`
-
Run the executable:
# Inside a repo you can do commi --copy # or run it from everywhere and pass the repo path as an argument commi --repo "/path/to/your/repo" --commit
You can install Commi using pip:
pip install commi
Run the executable:
# Inside a repo you can do
commi --generate
# or run it from everywhere and pass the repo path as an argument
commi --repo "/path/to/your/repo" --generate
You can also download the pre-built binary for your system from the releases page.
Now you're ready to use Commi!
After installation, you can use the command-line interface (CLI) to generate commit messages.
To generate a commit message based on the latest changes in your repository:
commi --repo "/path/to/your/repo"
If you want to generate a commit message based on the staged changes:
commi --repo "/path/to/your/repo" --cached
You can provide your API key directly via the --api-key
option:
commi --repo "/path/to/your/repo" --api-key "your_api_key"
Alternatively, you can set the API key as an environment variable:
export COMMI_API_KEY="your_api_key"
commi --repo "/path/to/your/repo"
If no API key is provided, a default API key will be used.
To copy the generated commit message to your clipboard, use the --copy
flag:
commi --repo "/path/to/your/repo" --copy
This requires the installation of xclip
(on Linux systems). If it's not installed, Commi will attempt to install it automatically.
To regenerate the commit message, you can use the --regenerate
flag, which will generate a new commit message based on the latest changes.
commi --repo "/path/to/your/repo" --regenerate
To commit the generated commit message, use the --commit
flag:
commi --repo "/path/to/your/repo" --commit
Commi uses a .env
file to configure certain settings. You can modify the following settings:
COMMI_API_KEY
: Your Gemini AI API key.MODEL_NAME
: The AI model to use for commit message generation (e.g.,gemini-1.5-flash
).
We welcome contributions to Commi! If you find a bug or want to suggest a new feature, please open an issue or submit a pull request.
- Fork the repository.
- Create a new branch for your feature (
git checkout -b feature-name
). - Commit your changes (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature-name
). - Create a new pull request.
Commi is open-source software licensed under the MIT License. See the LICENSE file for more details.