gg add
Interactively stage files for commit with checkbox selection.
Usage
bash
gg add # Interactive selection of all changed files
gg add file1 file2 # Add specific files
# Shorthand
gg aFeatures
- Multi-select interface - Choose multiple files with checkbox selection
- Visual feedback - See which files are selected before staging
- Confirmation - Review your selection before staging
- File status indicators - See modified, new, and deleted files at a glance
Interactive Mode
When you run gg add without arguments, GitGuru presents an interactive interface where you can select which files to stage:
bash
$ gg add
? Select files to stage: (Press <space> to select, <a> to toggle all, <i> to invert)
❯ ◯ modified: src/app.ts
◯ modified: src/utils/helper.ts
◯ new file: src/components/Button.tsx
◯ deleted: src/old-file.tsKeyboard Shortcuts
Space- Toggle selection of current filea- Toggle all filesi- Invert selectionEnter- Confirm and stage selected files
Adding Specific Files
You can also add specific files directly:
bash
# Add a single file
gg add src/app.ts
# Add multiple files
gg add src/app.ts src/utils/helper.ts
# Add all files in a directory
gg add src/components/Examples
Typical Workflow
bash
# 1. Check what files have changed
gg status
# 2. Interactively select files to stage
gg add
# 3. Review staged changes
gg diff --staged
# 4. Commit with AI-generated message
gg commit --aiSelective Staging
Stage only the files related to a specific feature:
bash
# Stage only authentication-related files
gg add src/auth/login.ts src/auth/logout.ts src/utils/token.ts
# Or use interactive mode and select them
gg addComparison with git add
| Feature | git add | gg add |
|---|---|---|
| Add specific files | ✓ | ✓ |
| Add all files | git add . | Select all in interactive mode |
| Interactive selection | git add -i (complex) | ✓ (user-friendly) |
| Visual file status | ✗ | ✓ |
| Confirmation before staging | ✗ | ✓ |
Best Practices
Create Atomic Commits
Stage related changes together for meaningful commits:
bash
# Good: Stage related files together
gg add src/auth/login.ts src/auth/types.ts tests/auth.test.ts
gg commit --ai # AI will generate: "feat: implement user login functionality"
# Avoid: Staging unrelated changes
# Don't mix bug fixes with new features in the same commitReview Before Staging
Always check what you're about to stage:
bash
# Check status first
gg status
# Use interactive mode to review and select
gg add
# Verify what got staged
gg diff --stagedPro Tip
Use
gg status before and after gg add to ensure you've staged exactly what you intended.Troubleshooting
Accidentally Staged Wrong Files?
If you staged files by mistake, you can unstage them:
bash
# Unstage a specific file
gg ask "unstage src/wrong-file.ts"
# Unstage all files
gg ask "unstage all files"No Files to Stage?
If gg add shows no files:
- Check if you have any changes with
gg status - Make sure you're in the correct directory
- Verify the files aren't already staged