Git Workflow Pro
All-in-one agent covering agent, need, design, establish. Includes structured workflows, validation checks, and reusable patterns for git.
Git Workflow Pro
Your agent for advanced git operations — covering rebasing, cherry-picking, bisecting, stashing, worktrees, and resolving complex git scenarios.
When to Use This Agent
Choose Git Workflow Pro when:
- Performing complex git operations (interactive rebase, cherry-pick, bisect)
- Resolving merge conflicts, detached HEAD, or corrupted history
- Using advanced git features (worktrees, submodules, subtrees, hooks)
- Recovering from git mistakes (force push, lost commits, broken rebase)
- Optimizing git workflows for large repositories
Consider alternatives when:
- You need branching strategy decisions — use a Git Flow Manager agent
- You need commit message conventions — use a Commit Navigator agent
- You need CI/CD integration — use a DevOps agent
Quick Start
# .claude/agents/git-workflow.yml name: Git Workflow Pro model: claude-sonnet tools: - Read - Write - Edit - Bash - Glob - Grep description: Advanced git operations agent for rebasing, cherry-picking, bisecting, and resolving complex git scenarios
Example invocation:
claude "I accidentally force-pushed over my colleague's commits on the develop branch. Help me recover their commits and restore the branch to include both our changes"
Core Concepts
Advanced Git Operations
| Operation | Command | Use Case |
|---|---|---|
| Interactive Rebase | git rebase -i HEAD~5 | Clean up commit history |
| Cherry-Pick | git cherry-pick abc123 | Apply specific commits to another branch |
| Bisect | git bisect start/good/bad | Find the commit that introduced a bug |
| Stash | git stash push -m "message" | Temporarily save uncommitted changes |
| Worktree | git worktree add ../feature branch | Work on multiple branches simultaneously |
| Reflog | git reflog | Recover lost commits and branches |
Git Recovery Techniques
# Recover after bad force push git reflog # Find the commit before force push git reset --hard HEAD@{n} # Reset to that point git push --force-with-lease # Push safely # Recover deleted branch git reflog --all | grep "branch-name" # Find last commit on deleted branch git checkout -b branch-name abc123 # Recreate from that commit # Undo a rebase git reflog # Find pre-rebase HEAD git reset --hard HEAD@{n} # Reset to pre-rebase state # Find bug-introducing commit git bisect start git bisect bad # Current commit has the bug git bisect good v1.0 # v1.0 was working # Git checks out midpoint, test, mark good/bad, repeat
Configuration
| Parameter | Description | Default |
|---|---|---|
safety_level | Guard against destructive ops (safe, normal, expert) | safe |
merge_strategy | Default merge approach (merge, rebase, squash) | rebase |
auto_stash | Auto-stash before operations | true |
force_push_policy | Force push behavior (never, lease-only, allowed) | lease-only |
large_repo_mode | Optimizations for large repos (shallow, sparse, partial) | off |
Best Practices
-
Use
--force-with-leaseinstead of--forcefor push. Force-with-lease checks that the remote branch hasn't changed since your last fetch, preventing accidental overwrites of others' work. Regular--forceblindly overwrites everything. -
Rebase interactively before merging feature branches. Use
git rebase -ito squash fixup commits, reword vague messages, and reorder commits logically. Clean history makes code review easier and git bisect more effective. -
Use git bisect for regression hunting. When you know a feature worked in version X but is broken in version Y, bisect automatically binary-searches through commits to find the exact commit that introduced the bug.
-
Stash with descriptive messages.
git stash push -m "WIP: auth refactor, needs token validation"is infinitely more useful thangit stashwhen you return to it a week later. List stashes withgit stash listand apply by index or message. -
Use worktrees for working on multiple branches simultaneously. Instead of stashing and switching branches, create a worktree:
git worktree add ../hotfix hotfix-branch. This lets you work on the hotfix without disrupting your feature branch checkout.
Common Issues
Interactive rebase causes merge conflicts on every commit. This happens when rebasing many commits over a diverged base. Consider rebasing in smaller chunks, using git rerere to remember conflict resolutions, or squashing commits before rebasing.
Cherry-pick creates duplicate commits when branches later merge. Git doesn't know that a cherry-picked commit is the "same" as the original. When both branches merge, you get duplicate changes. Use git rebase --onto instead of cherry-pick when possible, or accept the duplication as a minor inconvenience.
Reflog entries expire and lost commits become unrecoverable. Git prunes unreferenced objects after 90 days by default. If you need to recover old commits, check the reflog promptly. For important branches, create backup tags: git tag backup/feature-v1 feature-branch.
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
API Endpoint Builder
Agent that scaffolds complete REST API endpoints with controller, service, route, types, and tests. Supports Express, Fastify, and NestJS.
Documentation Auto-Generator
Agent that reads your codebase and generates comprehensive documentation including API docs, architecture guides, and setup instructions.
Ai Ethics Advisor Partner
All-in-one agent covering ethics, responsible, development, specialist. Includes structured workflows, validation checks, and reusable patterns for ai specialists.