Stage all changes and generate a commit message using OpenAI gpt-5 with one command.
What it does:
git add . && git diff --staged | english | git commit -F -- Generates clear and concise commit messages following conventional commits format
- Automatically analyzes staged git changes
- Configurable file exclusions
- Token counting and cost estimation
- Clone the repository:
git clone https://github.com/preynal/git-ai
cd ./git-ai- Install dependencies:
yarn
# or
npm install- Configure OpenAI API key:
Create a
.envfile in the root directory:
OPENAI_API_KEY=your-api-key
Add a git ai alias to your ~/.gitconfig file:
[alias]
ai = "!node <PATH_TO_CLONED_DIR>/git-ai.js"Then in any git reposoritory, you can run:
git ai
It will add all changes to the staging area, generate a commit message, and you can approve it by pressing Enter.
The tool can be configured through src/config.js:
systemMessage: Custom prompt for the AIexcludedFiles: Array of files to exclude from the diff analysismodelName: GPT model to use (default:gpt-5)pricePerMillionTokens: pricing used for local cost estimation
- Tested on Node.js 22 LTS
- Git
- OpenAI API key
MIT