Common Tasks
Quick solutions for everyday Git operations using GitGuru.
Undoing Changes
Undo Last Commit
bash
# Keep changes staged
gg ask "undo last commit but keep changes"
# Keep changes unstaged
gg ask "undo last commit and unstage changes"
# Completely discard last commit
gg ask "undo last commit and discard changes"Undo Multiple Commits
bash
# Undo last 3 commits
gg ask "undo last 3 commits but keep changes"
# Undo commits up to a specific commit
gg ask "reset to commit abc123"Undo Changes in a File
bash
# Discard changes in working directory
gg ask "discard changes in src/app.ts"
# Restore file to specific commit
gg ask "restore src/app.ts from commit abc123"Unstage Files
bash
# Unstage a specific file
gg ask "unstage src/app.ts"
# Unstage all files
gg ask "unstage all files"Viewing History
View Recent Commits
bash
# Show last 10 commits
gg log
# Show last 20 commits with AI analysis
gg log -n 20 --ai
# Show commits with graph
gg log --graphFind a Specific Commit
bash
# Find commit by message
gg ask "find commit with message containing 'login bug'"
# Find commit that changed a file
gg ask "show commits that changed src/auth/login.ts"
# Find commits by author
gg ask "show commits by John"View File History
bash
# Who changed this file
gg ask "show who changed src/app.ts"
# History of a specific file
gg ask "show commit history for src/app.ts"Branch Operations
Create New Branch
bash
# Create and switch to new branch
gg branch -c feature/new-feature
# Create branch from specific commit
gg ask "create branch feature/fix from commit abc123"Switch Branches
bash
# Interactive branch selector
gg branch
# Switch to specific branch
gg ask "switch to branch develop"Rename Branch
bash
# Rename current branch
gg ask "rename current branch to feature/better-name"
# Rename specific branch
gg ask "rename branch old-name to new-name"Delete Branches
bash
# Delete a specific branch
gg branch -d feature/old-feature
# Delete all merged branches
gg ask "delete all local branches that have been merged to main"Merging and Rebasing
Merge a Branch
bash
# Merge branch into current
gg ask "merge feature/login into current branch"
# Merge with no fast-forward
gg ask "merge feature/login with no fast-forward"Rebase Operations
bash
# Rebase current branch onto main
gg ask "rebase my branch onto main"
# Interactive rebase to squash commits
gg ask "interactive rebase last 5 commits"Rebase Caution
Never rebase commits that have been pushed to a shared branch. This rewrites history and can cause problems for your team.
Resolve Merge Conflicts
bash
# Get help with conflicts
gg explain conflict
# See conflicted files
gg status
# After resolving manually, continue
gg ask "continue merge after resolving conflicts"Stashing Changes
Stash Your Work
bash
# Stash changes
gg ask "stash my changes"
# Stash with message
gg ask "stash my changes with message 'work in progress on login'"Apply Stashed Changes
bash
# Apply most recent stash
gg ask "apply last stash"
# Apply and remove from stash list
gg ask "pop last stash"
# List all stashes
gg ask "show all stashes"Remote Operations
Push Changes
bash
# Normal push
gg push
# Push new branch
gg ask "push and set upstream for current branch"
# Force push (use carefully!)
gg push --forcePull Changes
bash
# Normal pull
gg pull
# Pull with rebase
gg pull --rebaseTrack Remote Branch
bash
# Set upstream branch
gg ask "set upstream to origin/main"
# Track a remote branch
gg ask "track remote branch origin/feature/new"Working with Tags
bash
# Create a tag
gg ask "create tag v1.0.0"
# Create annotated tag with message
gg ask "create tag v1.0.0 with message 'Initial release'"
# List all tags
gg ask "show all tags"
# Push tags to remote
gg ask "push all tags"
# Delete a tag
gg ask "delete tag v0.9.0"Cleaning Up
Clean Untracked Files
bash
# See what would be deleted (safe)
gg ask "show untracked files"
# Delete untracked files (careful!)
gg ask "delete all untracked files"
# Delete untracked files in specific directory
gg ask "delete untracked files in dist folder"Clean Up Branches
bash
# Delete merged local branches
gg ask "delete all local branches that have been merged"
# Prune remote tracking branches
gg ask "prune deleted remote branches"Getting Information
Repository Information
bash
# Current branch
gg ask "what branch am I on"
# Remote information
gg ask "show remote URLs"
# Repository status with AI insights
gg status --aiViewing Differences
bash
# All changes
gg diff
# Staged changes only
gg diff --staged
# Changes in specific file
gg diff --file src/app.ts
# AI summary of changes
gg diff --aiQuick Reference Table
| Task | Command |
|---|---|
| Undo last commit | gg ask "undo last commit" |
| Create branch | gg branch -c feature/name |
| AI commit | gg commit --ai |
| View changes | gg diff --ai |
| Sync with remote | gg sync |
| Learn Git concept | gg explain "topic" |
Next Steps
- Workflows - Complete workflow examples
- Advanced Usage - Power user techniques
- gg ask Reference - Full command documentation