Automate commit message creation with a script that fetches Git diffs, sends them to ChatGPT for generating commit messages, and commits with the auto-generated message.
-
Clone this repository:
git clone https://github.com/your-repo/GitCommitGPT.git cd GitCommitGPT -
Create a symbolic link to make the script globally accessible:
sudo ln -s /path/to/GitCommitGPT/gitcommitgpt /usr/bin/gitcommitgpt
Verify the link:
ls -l /usr/bin/gitcommitgpt
-
(Optional) Install clipboard utilities for easier usage:
- Install
wl-clipboard(for Wayland environments):sudo apt install wl-clipboard
- Install
xclip(for X11 environments):sudo apt install xclip
- Install
xsel(alternative for X11):sudo apt install xsel
These utilities allow the generated commit message to be automatically copied to the clipboard.
- Install
-
Stage changes in your Git repository:
git add . -
Run the script to generate a commit message:
gitcommitgpt
-
The script will:
- Check for staged changes.
- Fetch the
git diffand generate a meaningful commit message using ChatGPT. - Copy the commit message to the clipboard (if
wl-clipboard,xclip, orxselis installed).
-
Review and commit the changes:
git commit -m "$(wl-paste)"If using
xclip:git commit -m "$(xclip -o)"Or, if using
xsel:git commit -m "$(xsel --clipboard --output)"
- Bash
- Git
wl-clipboard(for Wayland environments)xcliporxsel(for X11 environments, optional for clipboard functionality)