Skip to main content
The commit command is GitWhisper’s primary feature. It analyzes your staged changes and generates intelligent, contextual commit messages using AI.

Basic Usage

gitwhisper commit
# or use the shorthand
gw commit
By default, GitWhisper will:
  1. Check for staged changes in your repository
  2. Analyze the diff using the default AI model (or prompt you to select one)
  3. Generate a commit message
  4. Create the commit

Command Options

--model
string
default:"openai"
AI model to use for generating commit messages.Allowed values:
  • claude - Anthropic Claude
  • openai - OpenAI GPT models
  • gemini - Google Gemini
  • grok - xAI Grok
  • llama - Meta Llama
  • deepseek - DeepSeek, Inc.
  • github - GitHub Models
  • ollama - Ollama (local models)
  • free - Free tier via LLM7.io (no API key required)
Shorthand: -m
--key
string
API key for the selected model. If not provided, GitWhisper will check:
  1. Saved configuration (via gw save-key)
  2. Environment variables
Not required for ollama and free models.Shorthand: -k
--model-variant
string
Specific variant of the AI model to use.Examples:
  • gpt-4o (OpenAI)
  • claude-sonnet-4-20250514 (Claude)
  • gemini-2.0-flash (Gemini)
See list-variants for all available variants.Shorthand: -v
--prefix
string
Add a prefix to the commit message, useful for ticket numbers or issue references.Example: JIRA-123, GH-456Shorthand: -p
--auto-push
boolean
default:"false"
Automatically push the commit to the remote repository after creating it.Shorthand: -a
--confirm
boolean
default:"false"
Prompt for confirmation before applying the commit message. When enabled, you can:
  • commit - Accept the generated message
  • edit - Open in your git editor to modify
  • retry - Regenerate with the same or different model
  • discard - Cancel the commit
Shorthand: -cNote: Can be set as default via gw set-defaults --confirm-commits
--tag
string
Create a git tag for this commit.Example: v1.0.0, release-2024-03Shorthand: -t

Usage Examples

gw commit

Terminal Output Example

$ gw commit
Analyzing staged changes using openai (gpt-4o)...

---------------------------------
feat: add user authentication module

Implement JWT-based authentication with:
- Login and logout endpoints
- Token refresh mechanism
- Password hashing with bcrypt
- Session management
---------------------------------

[main abc1234] feat: add user authentication module
 4 files changed, 156 insertions(+), 12 deletions(-)

Workflow Scenarios

No Staged Changes

If you haven’t staged any changes, GitWhisper will:
  1. Detect unstaged or untracked files
  2. Prompt you to stage them automatically
  3. Proceed with commit generation
If always-add is enabled, this happens automatically without prompting.

Large Diffs

For very large changesets, GitWhisper automatically:
  1. Processes files individually
  2. Generates summaries for each file
  3. Combines summaries into a cohesive commit message
The default threshold is 50,000 characters (configurable via gw set-defaults --max-diff-size).

Large Files

GitWhisper warns about large files (>10MB by default) and offers options to:
  • Proceed anyway
  • Add to .gitignore and unstage
  • Cancel the commit

Multi-Repository Support

If run from a parent directory containing multiple git repositories, GitWhisper will:
  1. Detect all subdirectories with staged changes
  2. Generate individual commits for each repository
  3. Report success/failure for each

Environment Variables

API keys can be provided via environment variables:
export OPENAI_API_KEY="sk-..."
export ANTHROPIC_API_KEY="sk-ant-..."
export GEMINI_API_KEY="..."
export GROK_API_KEY="..."
export LLAMA_API_KEY="..."
export DEEPSEEK_API_KEY="..."

Build docs developers (and LLMs) love