gitcommit is a command-line tool that uses OpenAI's GPT models to generate concise and properly formatted Git commit messages based on staged changes. It simplifies the process of creating meaningful commit messages, ensuring consistency and clarity in your Git history.
- Automatically generates commit messages based on
git diffoutput. - Supports a test mode for previewing the commit message.
- User confirmation before committing changes.
-
Python 3.9 or higher: Ensure Python is installed on your system. You can check your Python version with:
python3 --version
-
Git: Make sure Git is installed. You can check by running:
git --version
-
Clone this repository:
git clone https://github.com/jeffreality/gitcommit.git cd gitcommit -
Run the setup script:
python3 setup.py
The script will:
- Prompt you for your OpenAI API key (see below for obtaining the key).
- Create a virtual environment.
- Install required dependencies.
- Install the
gitcommitcommand globally.
-
Obtain an OpenAI API key:
- Sign up or log in to OpenAI at https://platform.openai.com/.
- Navigate to the API section and generate a new API key.
- Paste the key when prompted during the setup process.
-
Stage your changes using Git:
git add <file>
-
Run
gitcommitto generate a commit message and apply it:gitcommit
- You'll see the generated commit message and be prompted to confirm the commit.
- To preview the message without committing, use:
gitcommit --test
-
After confirming the commit, you can push your changes:
git push
The following are some ideas for future enhancement:
- Command-line options:
- Specify a custom maximum number of tokens for message generation (to override the default).
- Customize the GPT model dynamically.
- Automatic Git push: Add an option to automatically push commits after confirmation.
- Enhanced support for other operating systems: Add detailed setup instructions for Linux and Windows.
- Customizable message templates: Allow users to provide templates for commit message formats.
- Support for other LLMs: Expand to use additional LLMs like Claude or Gemini for commit suggestions.
Contributions are welcome! If you have ideas for enhancements, bug fixes, or additional features, feel free to:
- Fork this repository.
- Create a new branch for your feature or fix.
- Submit a pull request.
This project is licensed under the MIT License.
If you encounter any issues, please open an issue in the GitHub Issues section.