Git Advanced Workflows skill for Claude

Master advanced Git workflows including rebasing, cherry-picking, bisect, worktrees, and reflog to maintain clean history and recover from any situation.

When Claude uses it

Use when managing complex Git histories, collaborating on feature branches, or troubleshooting repository issues.

Git Advanced Workflows SKILL.md

The full skill file from wshobson/agents (MIT).

Git Advanced Workflows

Master advanced Git techniques to maintain clean history, collaborate effectively, and recover from any situation with confidence.

When to Use This Skill

  • Cleaning up commit history before merging
  • Applying specific commits across branches
  • Finding commits that introduced bugs
  • Working on multiple features simultaneously
  • Recovering from Git mistakes or lost commits
  • Managing complex branch workflows
  • Preparing clean PRs for review
  • Synchronizing diverged branches

Core Concepts

1. Interactive Rebase

Interactive rebase is the Swiss Army knife of Git history editing.

Common Operations:

  • pick: Keep commit as-is
  • reword: Change commit message
  • edit: Amend commit content
  • squash: Combine with previous commit
  • fixup: Like squash but discard message
  • drop: Remove commit entirely

Basic Usage:

# Rebase last 5 commits
git rebase -i HEAD~5

# Rebase all commits on current branch
git rebase -i $(git merge-base HEAD main)

# Rebase onto specific commit
git rebase -i abc123

2. Cherry-Picking

Apply specific commits from one branch to another without merging entire branches.

# Cherry-pick single commit
git cherry-pick abc123

# Cherry-pick range of commits (exclusive start)
git cherry-pick abc123..def456

# Cherry-pick without committing (stage changes only)
git cherry-pick -n abc123

# Cherry-pick and edit commit message
git cherry-pick -e abc123

3. Git Bisect

Binary search through commit history to find the commit that introduced a bug.

# Start bisect
git bisect start

# Mark current commit as bad
git bisect bad

# Mark known good commit
git bisect good v1.0.0

# Git will checkout middle commit - test it
# Then mark as good or bad
git bisect good  # or: git bisect bad

# Continue until bug found
# When done
git bisect reset

Automated Bisect:

# Use script to test automatically
git bisect start HEAD v1.0.0
git bisect run ./test.sh

# test.sh should exit 0 for good, 1-127 (except 125) for bad

4. Worktrees

Work on multiple branches simultaneously without stashing or switching.

# List existing worktrees
git worktree list

# Add new worktree for feature branch
git worktree add ../project-feature feature/new-feature

# Add worktree and create new branch
git worktree add -b bugfix/urgent ../project-hotfix main

# Remove worktree
git worktree remove ../project-feature

# Prune stale worktrees
git worktree prune

5. Reflog

Your safety net - tracks all ref movements, even deleted commits.

# View reflog
git reflog

# View reflog for specific branch
git reflog show feature/branch

# Restore deleted commit
git reflog
# Find commit hash
git checkout abc123
git branch recovered-branch

# Restore deleted branch
git reflog
git branch deleted-branch abc123

Detailed patterns and worked examples

Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.

Best Practices

  1. Always Use --force-with-lease: Safer than --force, prevents overwriting others' work
  2. Rebase Only Local Commits: Don't rebase commits that have been pushed and shared
  3. Descriptive Commit Messages: Future you will thank present you
  4. Atomic Commits: Each commit should be a single logical change
  5. Test Before Force Push: Ensure history rewrite didn't break anything
  6. Keep Reflog Aware: Reflog is your safety net, but entries for commits not reachable from the current tip expire after 30 days by default (gc.reflogExpireUnreachable), and reachable entries after 90 days (gc.reflogExpire)
  7. Branch Before Risky Operations: Create backup branch before complex rebases
# Safe force push
git push --force-with-lease origin feature/branch

# Create backup before risky operation
git branch backup-branch
git rebase -i main
# If something goes wrong
git reset --hard backup-branch

Common Pitfalls

  • Rebasing Public Branches: Causes history conflicts for collaborators
  • Force Pushing Without Lease: Can overwrite teammate's work
  • Losing Work in Rebase: Resolve conflicts carefully, test after rebase
  • Forgetting Worktree Cleanup: Orphaned worktrees consume disk space
  • Not Backing Up Before Experiment: Always create safety branch
  • Bisect on Dirty Working Directory: Commit or stash before bisecting

Recovery Commands

# Abort operations in progress
git rebase --abort
git merge --abort
git cherry-pick --abort
git bisect reset

# Restore file to version from specific commit
git restore --source=abc123 path/to/file

# Undo last commit but keep changes
git reset --soft HEAD^

# Undo last commit and discard changes
# WARNING: --hard also deletes uncommitted changes (staged and unstaged),
# and the reflog cannot recover them. Check `git status` and stash first.
git reset --hard HEAD^

# Recover a deleted branch soon. By default, git gc can prune HEAD's reflog
# entries for unmerged commits once they're 30 days old, counted from when
# each entry was recorded, not from the deletion
# Deleting a branch also deletes its own reflog; search HEAD's reflog
git reflog
git branch recovered-branch abc123

How to install Git Advanced Workflows

Claude Code

Copy the skill into your personal skills folder (or into .claude/skills/ inside a project):

npx degit wshobson/agents/plugins/developer-essentials/skills/git-advanced-workflows#main ~/.claude/skills/git-advanced-workflows

Codex

npx degit wshobson/agents/plugins/developer-essentials/skills/git-advanced-workflows#main ~/.codex/skills/git-advanced-workflows

Claude.ai and Claude Desktop

Download the skill folder from GitHub, zip it, and upload it under Settings → Capabilities → Skills.

Frequently asked questions

+What does the Git Advanced Workflows skill do?

Master advanced Git workflows including rebasing, cherry-picking, bisect, worktrees, and reflog to maintain clean history and recover from any situation. Use when managing complex Git histories, collaborating on feature branches, or troubleshooting repository issues.

+How do I install Git Advanced Workflows in Claude Code?

Copy the skill folder into ~/.claude/skills/git-advanced-workflows, for example with "npx degit wshobson/agents/plugins/developer-essentials/skills/git-advanced-workflows#main ~/.claude/skills/git-advanced-workflows". Claude Code loads it automatically and uses it when a task matches.

+Does Git Advanced Workflows work with ChatGPT or Codex?

Yes. Git Advanced Workflows uses the open SKILL.md format. In Codex, put the folder in ~/.codex/skills/git-advanced-workflows. In Claude.ai, zip the folder and upload it under Settings → Capabilities → Skills.

+Is Git Advanced Workflows free?

Git Advanced Workflows is published on GitHub by wshobson under the MIT license, which allows free use.

Related software development skills

  1. Code Review

    Review the changes since a fixed point (commit, branch, tag, or merge-base) along two axes: Standards (does the code follow this repo's…

    mattpocock/skills★ 327k
  2. Using Agent Skills

    Discovers and invokes agent skills. Use when starting a session, or when you need to decide which skill or workflow applies to the piece of…

    addyosmani/agent-skills★ 119k
  3. Build

    Fully automate a coding task with make-plan, do, and babysit.

    thedotmack/claude-mem★ 118k
  4. Go Concurrency Patterns

    Master Go concurrency with goroutines, channels, sync primitives, and context.

    wshobson/agents★ 43k
  5. Godot Gdscript Patterns

    Master Godot 4 GDScript patterns including signals, scenes, state machines, and optimization.

    wshobson/agents★ 43k
  6. Grounded Vault

    Use when maintaining a durable Markdown knowledge store that agents compile from sources, when every number or quote in a wiki page must…

    wshobson/agents★ 43k
  7. Langchain Architecture

    Design LLM applications using LangChain 1.x and LangGraph for agents, memory, and tool integration.

    wshobson/agents★ 43k
  8. Microservices Patterns

    Design microservices architectures with service boundaries, event-driven communication, and resilience patterns.

    wshobson/agents★ 43k
  9. Modern Javascript Patterns

    Master ES6+ features including async/await, destructuring, spread operators, arrow functions, promises, modules, iterators, generators, and…

    wshobson/agents★ 43k

See all software development skills →

More skills from wshobson

  1. Github Actions Templates

    Create production-ready GitHub Actions workflows for automated testing, building, and deploying applications.

    wshobson/agents★ 43k
  2. Gitlab Ci Patterns

    Build GitLab CI/CD pipelines with multi-stage workflows, caching, and distributed runners for scalable automation.

    wshobson/agents★ 43k
  3. Gitops Workflow

    Implement GitOps workflows with ArgoCD and Flux for automated, declarative Kubernetes deployments with continuous reconciliation.

    wshobson/agents★ 43k

All skills by wshobson →

Give your whole team an AI agent with skills

Cody runs managed AI agents your team can message in Slack, Teams, WhatsApp and the web, with 50+ business integrations, scheduled tasks and memory. No terminal required.