https://github.com/dvershinin/commitgpt
Automate your Git commit messages with AI-powered insights.
https://github.com/dvershinin/commitgpt
chatgpt commit git git-hooks prepare-commit-msg
Last synced: 10 months ago
JSON representation
Automate your Git commit messages with AI-powered insights.
- Host: GitHub
- URL: https://github.com/dvershinin/commitgpt
- Owner: dvershinin
- License: gpl-3.0
- Created: 2023-11-02T10:32:47.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-03T07:33:57.000Z (about 2 years ago)
- Last Synced: 2025-02-06T11:32:09.661Z (12 months ago)
- Topics: chatgpt, commit, git, git-hooks, prepare-commit-msg
- Language: Shell
- Homepage:
- Size: 20.5 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Git Commit Message Hook
## Description
This git hook automatically generates commit messages based on the changes made to the files in a repository.
## Prerequisites
- `jq`
- `curl`
- `git`
## Installation Instructions
Clone this repository:
````bash
git clone https://github.com/dvershinin/CommitGPT.git ~/.local/share/CommitGPT
````
Navigate to your project's git hooks directory. It is usually located in:
```bash
cd your-project/.git/hooks/
```
Create a symbolic link to the `prepare-commit-msg` hook from the cloned repository:
```bash
ln -s ~/.local/share/CommitGPT/prepare-commit-msg.sh prepare-commit-msg
```
```bash
chmod +x prepare-commit-msg
```
Configure the necessary environment variable `OPENAI_API_KEY` in your `.bashrc`, for example.
## Usage
Once installed, the hook will automatically run when you execute git commit in your project repository.
To automatically generate commit messages disregarding any user input (in automated scripts for example, you can use):
```bash
GIT_EDITOR=true git commit
```
## Configuring project goal
This step is optional, but it is recommended to configure the project goal in the `prepare-commit-msg` hook.
This will help generate more elaborate reasons as to *why* the changes introduced by commit was made
Navigate to the Repository:
Change directory into the repository where you want to configure the project goal.
Run the following command to set a custom prompt, for example:
```bash
git config commit.goal "assist in automating the process of generating commit messages"
```
The goal should be a text you would otherwise place while filling int the blanks in the sentence:
> The goal of the project is to ...
### Verifying the Configuration:
To verify that the configuration has been set correctly, you can use the following command:
```bash
git config --get commit.goal
```
This command will output the currently set goal, allowing you to confirm it’s correctly configured.