Skip to content

Automatically generate and suggest context-aware Git commit messages using OpenAI's GPT. This repository provides an easy-to-integrate solution to streamline your commit process and enhance commit message quality.

Notifications You must be signed in to change notification settings

Dmoment/gpt-commit-message-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GPT-Commit-Message-Helper

Automatically generate and suggest context-aware Git commit messages using OpenAI's GPT. This repository provides an easy-to-integrate solution to streamline your commit process and enhance commit message quality.

Prerequisites

  • Python 3
  • OpenAI API key

Installation

  1. Clone this repository:
git clone https://github.com/your-username/gpt-commit-message-helper.git
cd gpt-commit-message-helper
  1. Install the required Python packages:
pip install openai
  1. Set your OpenAI API key as an environment variable:
export OPENAI_API_KEY=your_api_key_here
  1. Copy the commit_with_suggestion.sh script to your target Git repository's root directory.

  2. Make the script executable:

chmod +x commit_with_suggestion.sh
  1. Create a Git alias to run the script. Run the following command in your terminal:
git config --global alias.scommit '!sh ./commit_with_suggestion.sh'

Usage

Instead of using git commit, use git scommit in your repository. This command will run the custom script, which will prompt you for the commit message with the GPT-generated suggestion. You can press ENTER to use the suggested commit message or type a custom one and press ENTER.

Example:

git add .
git scommit

Customization

You can customize the behavior of the script using the following environment variables:

  • GPT_COMMIT_MESSAGE_MODEL: The OpenAI language model to use for generating commit messages. The default value is text-davinci-002.
  • GPT_COMMIT_MESSAGE_MAX_TOKENS: The maximum number of tokens to generate in the commit message. The default value is 60.
  • GPT_COMMIT_MESSAGE_TEMPERATURE: The sampling temperature to use when generating the commit message. The default value is 0.7.
  • GPT_COMMIT_MESSAGE_STOP: A string or list of strings to use as stop words when generating the commit message. The default value is None.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

Automatically generate and suggest context-aware Git commit messages using OpenAI's GPT. This repository provides an easy-to-integrate solution to streamline your commit process and enhance commit message quality.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published