This tool leverages the power of Gemini AI to automatically generate meaningful Git commit messages. With this tool, you can streamline your commit process by obtaining well-structured commit messages based on your changes.
Warning
If you are using a free plan, the data will be sent to Google as training data. Paid plans do not send data to Google. For more details, please refer to the Plan information.
- Visit Google AI Studio.
- Sign in and obtain your API key from the dashboard.
-
Initialize the Project
Run the following command to install necessary packages and copy the
.env.examplefile to.env:npm run init-setup
-
Configure Your API Key
Open the newly created
.envfile and paste your API key in the appropriate place:GEMINI_API_KEY=your_api_key_here -
Global Setup (Optional)
To use the tool globally from any repository path, execute the following command:
npm run global-setup
This will link the tool globally so you can use the
ggccommand in any Git repository.
-
Check Executable Permission
You can verify that the script is executable by running:
ls -l path/to/index.js
-
Verify Global Link
Ensure the global link is created successfully with:
npm ls -g --depth=0
When choosing the "Edit the commit message directly" option, you can press the Tab key to show and modify the default value provided. This allows you to easily make changes to the suggested commit message.
Once the setup is complete, navigate to your repository and run:
ggcThe tool will automatically generate a Git commit message based on the changes in your staged files.
If you want to customize the prompt used to generate the commit message, you can modify it in the .env file by setting the CUSTOM_PROMPT variable:
CUSTOM_PROMPT="Your custom prompt text here"
Currently, the tool supports the following models for message generation:
gemini-1.5-flashgemini-1.0-pro
You can specify the model to use in the .env file by setting the GEMINI_MODEL variable:
GEMINI_MODEL=gemini-1.5-flash
If you need to remove the global symbolic link, run:
npm unlink -g generate-commit-msg-by-geminiTo remove the executable permission from the script, run:
chmod -x path/to/index.jsFeel free to contribute to this project by submitting issues or pull requests.
This project is licensed under the MIT License