gg ask

AI Assistant

Ask GitGuru anything in natural language and get smart Git command suggestions with safety analysis.

Requires API Key
This command requires a Gemini API key. See Configuration for setup instructions.

Usage

bash
gg ask "<query>" [options]

Description

The gg ask command is your AI-powered Git assistant. Simply ask what you want to do in natural language, and GitGuru will analyze your question, understand your intent, and suggest the appropriate Git command. Each suggestion includes:

  • The exact Git command to run
  • A clear explanation of what the command does
  • A safety level indicator (Safe, Caution, or Dangerous)
  • An interactive prompt before execution

Options

OptionDescription
-y, --yesSkip confirmation and execute the command immediately
-h, --helpDisplay help information for this command

Examples

Undo Last Commit

bash
gg ask "undo last commit but keep changes"

GitGuru suggests: git reset --soft HEAD~1 (Safety: Caution)

Create and Switch Branch

bash
gg ask "create a new branch called feature-login"

GitGuru suggests: git checkout -b feature-login (Safety: Safe)

Save Work Temporarily

bash
gg ask "save my changes without committing"

GitGuru suggests: git stash push -m "WIP" (Safety: Safe)

Revert Changes

bash
gg ask "undo changes to a specific file"

GitGuru asks for the filename and suggests: git restore <file> (Safety: Caution)

Skip Confirmation

bash
gg ask "show git log" --yes

Executes immediately without prompting for confirmation.

Safety Levels

GitGuru analyzes every suggested command and assigns a safety level:

Safe

Read-only operations with no risk of data loss

Example: git status, git log

Caution

Modifies working directory but can be reversed

Example: git reset --soft, git stash

Dangerous

Can permanently delete data or rewrite history

Example: git reset --hard, git push --force

Review Before Executing
Always review the suggested command before confirming execution, especially for operations marked as Caution or Dangerous. GitGuru provides explanations to help you understand what will happen.

Common Use Cases

  • Undo operations: "undo last commit", "discard all changes"
  • Branch management: "switch to main branch", "delete remote branch"
  • Stashing: "save my work temporarily", "apply last stash"
  • History viewing: "show recent commits", "see file history"
  • Cleanup tasks: "remove untracked files", "prune remote branches"
  • Merging and rebasing: "merge develop into current branch", "rebase on main"

Tips

  • Be specific in your questions for better suggestions
  • You can ask follow-up questions to refine the suggestion
  • Use --yes flag only for safe, read-only operations
  • Always read the explanation before confirming dangerous operations