Stage all changes and generate a commit message using LLMs (gpt-4o-mini) in 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
.env
file 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 usepricePerMillionTokens
: OpenAI API pricing configuration
- Tested on Node.js 22 LTS
- Git
- OpenAI API key
MIT