Harness the power of AI to generate meaningful commit messages for your Git repository. Say goodbye to writing mundane commit messages and let ChatGPT take care of it for you!
Get Creative with your custom prompts!
Style | Message |
---|---|
[standard] | feat: Introduce Git AI Commit Messages script for automated generation of meaningful commit messages |
[angry engineer] | Ugh, seriously?! Adding that Git AI Commit Messages script just to spoon-feed us "meaningful" commit messages? Are we now so lazy that we can't even write our own damn messages? This is getting ridiculous. Fine, whatever, I've added the freakin' script for automated commit messages. Happy now? 🙄 |
[emoji] | ✨: Add Git 🤖 Commit Messages script for automatic generation of 👌 commit messages |
[uwu] | feat: Intwoduce Git AI Commit Messages scwipt fow automated genewation of meaningfuw commit messages! UwU 💬🌟 |
In software development, writing clear and concise commit messages is essential for maintaining a well-organized and understandable version history. With the Git AI Commit Messages script, you can automate the process of generating commit messages using the advanced capabilities of the GPT-3.5 language model from OpenAI.
Before using the script, make sure you have the following:
-
An API key from OpenAI: To interact with the GPT-3.5 model and generate commit messages, you'll need an API key. This key should be stored in a
config.txt
file located in the same directory as theai_commit.sh
script. -
Git: Ensure you have Git installed and configured on your system.
-
Clone this repository to your local machine.
-
Obtain an API key from OpenAI and place it in a file named
config.txt
in the same directory as theai_commit.sh
script.API_KEY="..."
-
Make the
ai_commit.sh
script executable:chmod +x ai_commit.sh
-
Stage your changes using Git:
git add .
-
Run the script:
./ai_commit.sh
-
The script will generate a commit message based on the changes you've staged. It will present the message to you and ask if you want to proceed with the generated message.
-
If you choose to commit the changes with the generated message, the script will automatically create a commit using Git with the generated commit message.
-
Create a file named
config.txt
in the same directory as the script. -
Open
config.txt
in a text editor and any of the supported keys:# (required) OpenAI API key API_KEY="your_actual_api_key_here" # (optional) Override for the ai prompt OVERRIDE_PROMPT="Write your custom commit message prompt here such as: Write a commit message using only emoji's for the given diff."
Please note that the alias is completely optional, but it can save you even more time by providing a shorter and more memorable command for generating AI-generated commit messages.
To make running the ai_commit.sh
script even easier, you can set up a Git alias that maps to the script. This way, you can use a shorter command to invoke the script whenever you want to generate a commit message.
-
Open your terminal and navigate to your home directory by running:
cd ~
-
Open or create the
.gitconfig
file (if it doesn't exist) using a text editor of your choice:nano .gitconfig
-
Add the following lines to the
.gitconfig
file to create the alias:[alias] ai-commit = !/path/to/ai_commit.sh
Replace
/path/to
with the actual path to the directory containing theai_commit.sh
script. -
Save and exit the text editor.
-
Now you can use the alias to generate commit messages. From within your repository directory, simply run:
git ai-commit
The script will be executed, and you'll be guided through the process of generating and committing a message.
-
Open your terminal.
-
Edit your Zsh configuration file:
nano ~/.zshrc
-
Add the following lines to create the alias:
alias git-ai-commit='/path/to/ai_commit.sh'
Replace
/path/to
with the actual path to the directory containing theai_commit.sh
script. -
Save and exit the text editor.
-
Apply the changes:
source ~/.zshrc
-
Now you can use the alias to generate commit messages:
git-ai-commit
-
Open your terminal.
-
Edit your shell configuration file (e.g.,
.bashrc
,.bash_profile
, or.profile
):nano ~/.bashrc
-
Add the following lines to create the alias:
alias git-ai-commit='/path/to/ai_commit.sh'
Replace
/path/to
with the actual path to the directory containing theai_commit.sh
script. -
Save and exit the text editor.
-
Apply the changes:
source ~/.bashrc
-
Now you can use the alias to generate commit messages:
git-ai-commit
Feel free to modify the script according to your needs. You can adjust the prompts, the model used for text generation, and the formatting of commit messages. The script provides a foundation for integrating AI-generated commit messages into your workflow.
Remember that while AI-generated commit messages can save time, they might not always capture the full context of your changes. It's recommended to review and, if necessary, modify the generated messages to ensure accurate and meaningful version history.
Contributions to this project are welcome! If you have ideas for improvements, new features, or bug fixes, please open an issue or submit a pull request.
This project is licensed under the MIT License.
You're all set to streamline your Git commit message workflow with the Git AI Commit Messages script. Enjoy writing code while the AI takes care of your commit messages!