Commit Buddy is an open-source Command Line Interface (CLI) tool written in Go that leverages the Gemini API to automatically generate intelligent Git commit messages based on your staged changes. Say goodbye to generic commit messages and hello to a more descriptive and meaningful commit history!
-
AI-Powered Commit Messages: Generates concise and relevant commit messages by analyzing your
git diff --staged
output using the Gemini API. -
Seamless CLI Integration: Integrates directly into your Git workflow, allowing you to generate messages with simple commands.
-
Interactive Commit Prompt: Displays the generated
git commit -m "message"
command directly in your terminal's input line, allowing you to edit it, press Enter to commit, or Ctrl+C to abort, just like a normal terminal command. -
Open Source: Built with transparency and community contributions in mind.
Before you begin, ensure you have the following installed:
-
Go (1.16 or higher): Download and Install Go
-
Gemini API Key: You'll need an API key from Google's Gemini API. You can obtain one by following the instructions on the Google AI Studio website.
# bash -c "{curl -s https://github.com/winnerx0/commit-buddy.git
git clone https://github.com/winnerx0/commit-buddy.git
cd commit-buddy
go build -o cb .
This will create an executable named cb
in your current directory.
(Optional) Add to your PATH
:
# On Linux/macOS
sudo mv cb /usr/local/bin/
Commit Buddy requires your Gemini API key to function. It reads this key from an environment variable named GEMINI_API_KEY
.
Recommended for current session:
export GEMINI_API_KEY="YOUR_GEMINI_API_KEY_HERE"
For persistent setup:
-
Bash/Zsh: Add the export line to your
~/.bashrc
,~/.zshrc
, or~/.profile
file. -
Windows (Command Prompt):
setx GEMINI_API_KEY "YOUR_GEMINI_API_KEY_HERE"
-
Windows (PowerShell):
$env:GEMINI_API_KEY="YOUR_GEMINI_API_KEY_HERE" # To make it persistent, add this to your PowerShell profile script
Navigate to your Git repository, stage your changes, and then run Commit Buddy:
git add .
cb
Commit Buddy will then:
-
Fetch the staged changes (
git diff --staged
). -
Send the diff to the Gemini API.
-
Display the AI-generated commit message.
Generated Commit Message Example:
---
feat(user): Add new user authentication module
- Introduce a new authentication modul to handle user login and registration.
---
The git commit
command will then appear on your terminal's input line, pre-filled with the generated message. You can now:
-
Press Enter: To execute the command as is.
-
Press Ctrl+C: To abort the commit and exit Commit Buddy.
We welcome contributions to Commit Buddy! If you have ideas for new features, bug fixes, or improvements, please feel free to:
-
Fork the repository.
-
Create a new branch:
git checkout -b feature/your-feature-name
-
Make your changes.
-
Commit your changes:
git commit -m 'feat: Add new feature'
-
Push to the branch:
git push origin feature/your-feature-name
-
Open a Pull Request.
Please ensure your code adheres to Go best practices and includes appropriate tests.
This project is licensed under the MIT License - see the LICENSE file for details.Commit Buddy