commit
Generate AI-powered commit message and create a commit.
Synopsis:
gcop-rs commit [OPTIONS] [FEEDBACK...]Description:
Analyzes your staged changes, generates an AI commit message (conventional by default, configurable via commit.convention), and creates a git commit after your approval.
With --amend, gcop-rs rewrites the latest commit message instead of creating a new commit. If staged changes exist, they are included in the amended commit; otherwise gcop-rs regenerates the message from the current HEAD commit diff.
When --split is enabled (or [commit].split = true in config), gcop-rs groups staged files into multiple atomic commits and commits them sequentially.
Options:
| Option | Description |
|---|---|
--format <FORMAT>, -f | Output format: text (default) or json (json implies no commit) |
--json | Shortcut for --format json |
--no-edit, -n | Skip opening editor for manual editing |
--yes, -y | Skip confirmation menu and accept generated message |
--dry-run, -d | Only generate and print commit message, do not commit |
--split, -s | Split staged changes into multiple atomic commits |
--amend | Amend the latest commit with a newly generated message |
--provider <NAME>, -p | Use specific provider (overrides default) |
Feedback (optional):
You can append free-form text after the options to guide commit message generation.
# With quotes (recommended)
gcop-rs commit "use Chinese and be concise"
# Or without quotes (will be treated as one combined instruction)
gcop-rs commit use Chinese and be conciseNote: In JSON mode (
--json/--format json), gcop-rs runs non-interactively and does not create a commit (it only prints JSON output).
Split Mode (--split)
In split mode, gcop-rs asks the LLM to group staged files into atomic commit groups.
--yesapplies all generated groups directly (non-interactive).--dry-runonly previews generated groups, without creating commits.--jsonoutputs group data as JSON (groups,diff_stats,committed) and does not create commits.- In interactive mode, actions are:
Accept All,Edit,Regenerate,Regenerate with feedback,Quit.
Note: Split mode currently sends per-file diffs to the model and does not apply the global
[llm].max_diff_sizetruncation cap.
Note:
--splitand--amendare mutually exclusive.
Interactive Actions:
In normal (non-split) mode, after generating a message, you'll see a menu:
- Accept - Use the generated message and create commit
- Edit - Open your
$VISUAL/$EDITOR(platform default if not set) to manually modify the message (returns to menu after editing) - Retry - Regenerate a new message without additional instructions
- Retry with feedback - Provide instructions for regeneration (e.g., "use Chinese", "be more concise", "add more details"). Feedback accumulates across retries, allowing you to progressively refine the message
- Quit - Cancel the commit process
Examples:
# Basic usage
git add src/auth.rs
gcop-rs commit
# Skip all prompts
git add .
gcop-rs commit --no-edit --yes
# Use different provider
gcop-rs commit --provider openai
# Atomic split commits
gcop-rs commit --split
# Amend the latest commit message
gcop-rs commit --amend
# Verbose mode (see API calls)
gcop-rs -v commit
# JSON output for automation (does not create commit)
gcop-rs commit --json > commit.json
# Split mode JSON output (does not create commits)
gcop-rs commit --split --json > split-commit.jsonWorkflow:
$ git add src/auth.rs src/middleware.rs
$ gcop-rs commit
[1/4] Analyzing staged changes...
2 files changed, 45 insertions(+), 12 deletions(-)
ℹ Generated commit message:
feat(auth): implement JWT token validation
Add middleware for validating JWT tokens with proper
error handling and expiration checks.
[3/4] Choose next action...
Choose next action:
> Accept
Edit
Retry
Retry with feedback
Quit
[Selected: Accept]
[4/4] Creating commit...
✓ Commit created successfully!Tips:
- Stage only the changes you want in this commit before running
- Use
--yesin CI/CD pipelines to skip interactive prompts - Use
--json/--format jsonto generate a message for automation (no commit) - Use
--splitto create atomic commits when one staging set contains multiple logical changes - Try "Retry with feedback" if the message doesn't capture your intent
Output Format (json):
{
"success": true,
"data": {
"message": "feat(auth): implement JWT token validation",
"diff_stats": {
"files_changed": ["src/auth.rs", "src/middleware.rs"],
"insertions": 45,
"deletions": 12,
"total_changes": 57
},
"committed": false
}
}Output Format (json + split):
{
"success": true,
"data": {
"groups": [
{
"files": ["src/auth.rs", "src/middleware.rs"],
"message": "feat(auth): add JWT validation middleware"
},
{
"files": ["tests/auth_test.rs"],
"message": "test(auth): add JWT validation tests"
}
],
"diff_stats": {
"files_changed": ["src/auth.rs", "src/middleware.rs", "tests/auth_test.rs"],
"insertions": 58,
"deletions": 9,
"total_changes": 67
},
"committed": false
}
}