gitcai
v1.0.2
Published
AI-powered Git commit message generator CLI for Conventional Commits using Ollama or Gemini
Maintainers
Readme
gitcai - AI Git Commit Message Generator CLI
Generate Conventional Commit messages from your Git diff using Ollama or Gemini, then commit from your terminal.
gitcai is an AI Git commit message generator CLI. It reads your staged Git diff, asks Ollama or Gemini to write a clear Conventional Commit message, lets you edit the result, and runs git commit.
Quick Start
npm install -g gitcai
gitcaiWhat It Does
- Generates commit messages from your Git changes
- Creates Conventional Commit messages from staged diffs
- Supports
ollamaandgemini - Runs a first-time setup when you use it for the first time
- Lets you edit the generated commit message before committing
- Auto-stages files when nothing is staged
- Can push after commit with
--push - Stores user config outside your repository
- Automatically excludes lockfiles from the diff sent to AI to save tokens and improve message quality
Requirements
- Node.js 20 or newer
- Git
- One AI provider:
- Ollama local or remote server
- Gemini API key
Install
From npm
npm install -g gitcaiThen run:
gitcaiFrom Yarn
yarn global add gitcaiThen run:
gitcaiFrom This Repository
git clone https://github.com/VanChung369/gitcai.git
cd gitcai
yarn install
yarn build
yarn linkNow the gitcai command is available globally on your machine.
First-Time Setup
The first time you run:
gitcaithe tool asks for only the required setup:
- AI provider:
ollamaorgemini - Commit message language: English or Vietnamese
- Provider-specific values:
- Ollama: base URL and model
- Gemini: API key and model
You can also run setup manually:
gitcai config setupBasic Usage
Go to any Git repository:
cd path/to/your/repoRun:
gitcaiThe tool will:
- Read staged changes
- Auto-stage files if nothing is staged
- Generate a commit message
- Let you edit the message
- Ask for confirmation
- Run
git commit
Commit and push:
gitcai --pushSkip editing:
gitcai --no-editSkip confirmation:
gitcai --yesSkip both editing and confirmation:
gitcai --no-edit --yesDo not auto-stage files:
gitcai --no-stageOllama Setup
Local Ollama:
gitcai config set provider ollama
gitcai config set ollamaUrl http://localhost:11434
gitcai config set model qwen2.5:1.5bRemote Ollama:
gitcai config set provider ollama
gitcai config set ollamaUrl https://ai.example.com
gitcai config set model qwen2.5:1.5bUse without saving config:
gitcai --provider ollama --ollama-url http://localhost:11434 --model qwen2.5:1.5bGemini Setup
Save Gemini config:
gitcai config set provider gemini
gitcai config set model gemini-2.5-flash
gitcai config set geminiApiKey YOUR_API_KEYUse an environment variable instead:
set GEMINI_API_KEY=YOUR_API_KEY
gitcai --provider geminiOn macOS or Linux:
export GEMINI_API_KEY=YOUR_API_KEY
gitcai --provider geminiUse without saving config:
gitcai --provider gemini --gemini-api-key YOUR_API_KEY --model gemini-1.5-flashConfig Commands
Run setup again:
gitcai config setupShow all config:
gitcai config listGet one value:
gitcai config get providerSet one value:
gitcai config set language viReset config:
gitcai config resetShow config file path:
gitcai config pathConfig is stored in a user-level JSON file using conf. It is not committed to your project.
Useful Options
gitcai --provider ollama
gitcai --provider gemini
gitcai --language en
gitcai --language vi
gitcai --max-length 72
gitcai --max-diff-chars 10000
gitcai --temperature 0.2Ollama-specific:
gitcai --num-predict 40Gemini-specific:
gitcai --max-output-tokens 1280Troubleshooting
Current directory is not a Git repository
Run the command inside a Git repository:
cd path/to/your/repo
gitcaiOllama Request Timeout
If your Ollama server is slow or behind a proxy, reduce the diff size:
gitcai --max-diff-chars 2000 --num-predict 30Gemini API Key Missing
Set the key:
gitcai config set geminiApiKey YOUR_API_KEYor:
set GEMINI_API_KEY=YOUR_API_KEYDevelopment
yarn install
yarn dev -- --help
yarn dev -- config setup
yarn buildRun the built CLI:
node dist/cli.js --helpLink locally:
yarn build
yarn link
gitcai --helpUnlink:
yarn unlinkSecurity Notes
gitcai sends your staged diff to the configured AI provider. Do not use a remote provider for changes that contain secrets, credentials, private keys, or sensitive code.
