CommitAssistant is a Python script designed to generate commit messages intelligently and automatically by analyzing the differences (diff) in your Git repository. This project makes it easier to create more meaningful commits, saving time and ensuring consistent messages.
-
Commit message generation: Based on the changes detected by git diff, CommitAssistant creates automatic and contextual commit messages.
-
Flexible options:
- Complete Analysis: Analyzes all changes to the repository.
- Staged only: It only analyzes changes that are already staged (ready for commit).
- Specific file: Allows you to specify a single file for analyzing changes.
- Make sure you are in a Git project.
- Python 3.7 or higher installed.
There is currently no official installer, but you can create an alias to make it easier to use:
Add the following line to your ~/.bashrc
or ~/.zshrc:
alias commit-assistant='python3 /path/to/project/assistant.py'
After saving the file, reload the terminal:
source ~/.bashrc
# or
source ~/.zshrc
Set-Alias commit-assistant 'C:\path\to\project\assistant.py'
-
Analyze all changes:
commit-assistant
-
Only analyze staged changes:
commit-assistant --only-staged
-
Analyze a specific file:
commit-assistant --file-path Path/To/File.cs
command | alias | description |
---|---|---|
commit-assistant |
It analyzes all the changes in the repository and generates a commit message. | |
commit-assistant --only-staged |
-s |
It only analyzes the changes that are already staged. |
commit-assistant --file-path path/to/file.py |
-f path/to/file.py |
It analyzes a specific file to generate a commit message. |
CommitAssistant uses an assistant.cfg
configuration file to store your preferences:
[assistant.secrets]
# Your Gemini API key. You can get one here: https://aistudio.google.com/app/apikey
gemini.apiKey = YOU_GEMINI_API_KEY
[assistant.defaults]
# Default language for commit messages.
language = EN-US
# Maximum number of characters for commit messages.
maxNumberOfCharacters = 80
Don't forget to set the gemini.apiKey
in the assistant.cfg
file! It is essential for CommitAssistant to work. You can obtain your API key here.