Skip to content
/ git_ai Public

You already use AI to write your code, why are you still writing your commit messages?

License

Notifications You must be signed in to change notification settings

kgellci/git_ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Git AI Commit Messages

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!

git_ai

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 💬🌟

Introduction

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.

Prerequisites

Before using the script, make sure you have the following:

  1. 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 the ai_commit.sh script.

  2. Git: Ensure you have Git installed and configured on your system.

Usage

  1. Clone this repository to your local machine.

  2. Obtain an API key from OpenAI and place it in a file named config.txt in the same directory as the ai_commit.sh script.

    API_KEY="..."
  3. Make the ai_commit.sh script executable:

    chmod +x ai_commit.sh
  4. Stage your changes using Git:

    git add .
  5. Run the script:

    ./ai_commit.sh
  6. 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.

  7. 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.

config.txt

  1. Create a file named config.txt in the same directory as the script.

  2. 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."

Adding an Alias (Optional)

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.

Git alias

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.

  1. Open your terminal and navigate to your home directory by running:

    cd ~
  2. Open or create the .gitconfig file (if it doesn't exist) using a text editor of your choice:

    nano .gitconfig
  3. 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 the ai_commit.sh script.

  4. Save and exit the text editor.

  5. 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.

Zsh

  1. Open your terminal.

  2. Edit your Zsh configuration file:

    nano ~/.zshrc
  3. 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 the ai_commit.sh script.

  4. Save and exit the text editor.

  5. Apply the changes:

    source ~/.zshrc
  6. Now you can use the alias to generate commit messages:

    git-ai-commit

Bash or Other Terminals

  1. Open your terminal.

  2. Edit your shell configuration file (e.g., .bashrc, .bash_profile, or .profile):

    nano ~/.bashrc
  3. 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 the ai_commit.sh script.

  4. Save and exit the text editor.

  5. Apply the changes:

    source ~/.bashrc
  6. Now you can use the alias to generate commit messages:

    git-ai-commit

Customization

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.

Disclaimer

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.

Contributing

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.

License

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!

About

You already use AI to write your code, why are you still writing your commit messages?

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages