Master advanced Git workflows including rebasing

Git advanced workflows

by wshobson · MIT license · ★ 39,857 on GitHub · updated Sep 21

Git advanced workflows cover

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…

---
name: git-advanced-workflows
description: 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.
---

# 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

Overview

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

Manual install (npx, ZIP)
Claude Codenpx skills add wshobson/agents --skill git-advanced-workflows -g -a claude-code
Claude Code (manual)mkdir -p ~/.claude/skills && curl -sL https://codeload.github.com/wshobson/agents/tar.gz/4236bb91f839 \ | tar -xz -C ~/.claude/skills --strip-components=4 agents-4236bb91f839/plugins/developer-essentials/skills/git-advanced-workflows
Windows (PowerShell)New-Item -ItemType Directory -Force "$HOME\.claude\skills" | Out-Null; Invoke-WebRequest "https://m.agentalley.io/zip/17a981157ab8911bb040/git-advanced-workflows.zip" -OutFile "$env:TEMP\git-advanced-workflows.zip"; Expand-Archive "$env:TEMP\git-advanced-workflows.zip" -DestinationPath "$HOME\.claude\skills" -Force
Claude.ai / desktopDownload the ZIP and upload it under Settings → Capabilities → Skills.
Codex, Cursor, other agentsPoint them at SKILL.md. The other files are plain text.

Connects with Agent Alley MCP · agentalley.io/mcp

Files included

  • SKILL.md4.9 KB
  • references/1 file · 3.9 KB
Read the files here
wshobson/4236bb92 files
SKILL.md
Show the full text199 lines

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: Remember reflog is your safety net for 90 days
  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
git reset --hard HEAD^

# Recover deleted branch (within 90 days)
git reflog
git branch recovered-branch abc123
1---
2name: git-advanced-workflows
3description: 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.
4---
5 
6# Git Advanced Workflows
7 
8Master advanced Git techniques to maintain clean history, collaborate effectively, and recover from any situation with confidence.
9 
10## When to Use This Skill
11 
12- Cleaning up commit history before merging
13- Applying specific commits across branches
14- Finding commits that introduced bugs
15- Working on multiple features simultaneously
16- Recovering from Git mistakes or lost commits
17- Managing complex branch workflows
18- Preparing clean PRs for review
19- Synchronizing diverged branches
20 
21## Core Concepts
22 
23### 1. Interactive Rebase
24 
25Interactive rebase is the Swiss Army knife of Git history editing.
26 
27**Common Operations:**
28 
29- `pick`: Keep commit as-is
30- `reword`: Change commit message
31- `edit`: Amend commit content
32- `squash`: Combine with previous commit
33- `fixup`: Like squash but discard message
34- `drop`: Remove commit entirely
35 
36**Basic Usage:**
37 
38```bash
39# Rebase last 5 commits
40git rebase -i HEAD~5
41 
42# Rebase all commits on current branch
43git rebase -i $(git merge-base HEAD main)
44 
45# Rebase onto specific commit
46git rebase -i abc123
47```
48 
49### 2. Cherry-Picking
50 
51Apply specific commits from one branch to another without merging entire branches.
52 
53```bash
54# Cherry-pick single commit
55git cherry-pick abc123
56 
57# Cherry-pick range of commits (exclusive start)
58git cherry-pick abc123..def456
59 
60# Cherry-pick without committing (stage changes only)
61git cherry-pick -n abc123
62 
63# Cherry-pick and edit commit message
64git cherry-pick -e abc123
65```
66 
67### 3. Git Bisect
68 
69Binary search through commit history to find the commit that introduced a bug.
70 
71```bash
72# Start bisect
73git bisect start
74 
75# Mark current commit as bad
76git bisect bad
77 
78# Mark known good commit
79git bisect good v1.0.0
80 
81# Git will checkout middle commit - test it
82# Then mark as good or bad
83git bisect good # or: git bisect bad
84 
85# Continue until bug found
86# When done
87git bisect reset
88```
89 
90**Automated Bisect:**
91 
92```bash
93# Use script to test automatically
94git bisect start HEAD v1.0.0
95git bisect run ./test.sh
96 
97# test.sh should exit 0 for good, 1-127 (except 125) for bad
98```
99 
100### 4. Worktrees
101 
102Work on multiple branches simultaneously without stashing or switching.
103 
104```bash
105# List existing worktrees
106git worktree list
107 
108# Add new worktree for feature branch
109git worktree add ../project-feature feature/new-feature
110 
111# Add worktree and create new branch
112git worktree add -b bugfix/urgent ../project-hotfix main
113 
114# Remove worktree
115git worktree remove ../project-feature
116 
117# Prune stale worktrees
118git worktree prune
119```
120 
121### 5. Reflog
122 
123Your safety net - tracks all ref movements, even deleted commits.
124 
125```bash
126# View reflog
127git reflog
128 
129# View reflog for specific branch
130git reflog show feature/branch
131 
132# Restore deleted commit
133git reflog
134# Find commit hash
135git checkout abc123
136git branch recovered-branch
137 
138# Restore deleted branch
139git reflog
140git branch deleted-branch abc123
141```
142 
143## Detailed patterns and worked examples
144 
145Detailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient.
146 
147## Best Practices
148 
1491. **Always Use --force-with-lease**: Safer than --force, prevents overwriting others' work
1502. **Rebase Only Local Commits**: Don't rebase commits that have been pushed and shared
1513. **Descriptive Commit Messages**: Future you will thank present you
1524. **Atomic Commits**: Each commit should be a single logical change
1535. **Test Before Force Push**: Ensure history rewrite didn't break anything
1546. **Keep Reflog Aware**: Remember reflog is your safety net for 90 days
1557. **Branch Before Risky Operations**: Create backup branch before complex rebases
156 
157```bash
158# Safe force push
159git push --force-with-lease origin feature/branch
160 
161# Create backup before risky operation
162git branch backup-branch
163git rebase -i main
164# If something goes wrong
165git reset --hard backup-branch
166```
167 
168## Common Pitfalls
169 
170- **Rebasing Public Branches**: Causes history conflicts for collaborators
171- **Force Pushing Without Lease**: Can overwrite teammate's work
172- **Losing Work in Rebase**: Resolve conflicts carefully, test after rebase
173- **Forgetting Worktree Cleanup**: Orphaned worktrees consume disk space
174- **Not Backing Up Before Experiment**: Always create safety branch
175- **Bisect on Dirty Working Directory**: Commit or stash before bisecting
176 
177## Recovery Commands
178 
179```bash
180# Abort operations in progress
181git rebase --abort
182git merge --abort
183git cherry-pick --abort
184git bisect reset
185 
186# Restore file to version from specific commit
187git restore --source=abc123 path/to/file
188 
189# Undo last commit but keep changes
190git reset --soft HEAD^
191 
192# Undo last commit and discard changes
193git reset --hard HEAD^
194 
195# Recover deleted branch (within 90 days)
196git reflog
197git branch recovered-branch abc123
198```
199 
View all files on GitHub →

Details

Updated
Sep 21, 2026
License
MIT
Stars on the repo
★ 39,857
Checked
Source
wshobson/agents ↗
Creator
wshobson · 179 listings
View creator

Similar skills

See all →
SkillAutomates CI/CD pipeline setupCI/CD and Automationaddyosmani/agent-skills · by addyosmaniAutomates CI/CD pipeline setup. Use when setting up or modifying build and deployment pipelines. Use when you need to automate quality gates, configure test runners in CI, or establish deployment strategies.★ 98.7k GitHub starsSkillAutomated semantic versioning and release workflowVersion Bump & Release Workflowthedotmack/claude-mem · by thedotmackAutomated semantic versioning and release workflow for Claude Code plugins. Handles version increments across package.json, marketplace.json, plugin.json manifests, build verification, git tagging, GitHub releases, and changelog generation. NPM publishing is the final human-required handoff because the maintainer raised npm security.★ 95.6k GitHub starsSkillOperate Orca-managed worktrees, folder contexts, terminalsOrca CLIstablyai/orca · by stablyaiOperate Orca-managed worktrees, folder contexts, terminals, repos, automations, artifacts, skill sharing, worktree comments, and Orca's embedded browser through the `orca` CLI. Use when the user says "$orca-cli", "Orca worktree", "child worktree", "spawn codex/claude in a worktree", "read/wait/send Orca terminal", "handoff" / "handover" / "give this to another agent", "Orca browser", "orca artifacts", or "share skills". Prefer it over raw git worktree, ad hoc PTYs, or Computer Use when Orca state is involved. Use Computer Use only when a visible window needs GUI control that a CLI, filesystem, or API cannot do.★ 84.5k GitHub starsSkillThreaded messages, blocking ask/reply, task dispatchOrca Orchestrationstablyai/orca · by stablyaiCoordinate supervised Orca workers: threaded messages, blocking ask/reply, task dispatch, worker_done/escalation waits, task DAGs, decision gates, coordinator loops, and decomposing work across agents. Use `orca-cli` for full ownership handoffs — "hand off", "handoff", "handover", "give this to another agent", "another worktree" — unless asked to supervise, monitor, or coordinate a DAG, and for terminal control, lightweight terminal prompts, shell commands, Orca worktree management, and reading or waiting on terminals.★ 84.5k GitHub starsSkillDeploy applications and websites to VercelVercel deploybytedance/deer-flow · by bytedanceDeploy applications and websites to Vercel. Use this skill when the user requests deployment actions such as "Deploy my app", "Deploy this to production", "Create a preview deployment", "Deploy and give me the link", or "Push this live". No authentication required - returns preview URL and claimable deployment link.★ 83.5k GitHub starsSkillOpen or update a pull request on pascalorg/editorOpen PRpascalorg/editor · by pascalorgOpen or update a pull request on pascalorg/editor from the current branch, describing only what the branch actually did. Use when the user asks to open/create a PR, push and PR, or ship a branch in the editor repo.★ 24.6k GitHub stars

More from wshobson

SkillMaster C/.NET backend development patterns for buildingwshobson/agents · by wshobsonMaster C#/.NET backend development patterns for building robust APIs, MCP servers, and enterprise applications. Covers async/await, dependency injection, Entity Framework Core, Dapper, configuration, caching, and testing with xUnit. Use when developing .NET backends, reviewing C# code, or designing API architectures.★ 39.9k GitHub starsSkillImplement WCAG 2.2 compliant interfaces with mobileAccessibility compliancewshobson/agents · by wshobsonImplement WCAG 2.2 compliant interfaces with mobile accessibility, inclusive design patterns, and assistive technology support. Use when auditing accessibility, implementing ARIA patterns, building for screen readers, or ensuring inclusive user experiences.★ 39.9k GitHub starsSkillMaster Material Design 3 and Jetpack Compose patternsAndroid Mobile Designwshobson/agents · by wshobsonMaster Material Design 3 and Jetpack Compose patterns for building native Android apps. Use when designing Android interfaces, implementing Compose UI, or following Google's Material Design guidelines.★ 39.9k GitHub starsSkillMigrate from AngularJS to Angular using hybrid modeAngular migrationwshobson/agents · by wshobsonMigrate from AngularJS to Angular using hybrid mode, incremental component rewriting, and dependency injection updates. Use when upgrading AngularJS applications, planning framework migrations, or modernizing legacy Angular code.★ 39.9k GitHub starsSkillUnderstand anti-reversing, obfuscationAnti reversing techniqueswshobson/agents · by wshobsonUnderstand anti-reversing, obfuscation, and protection techniques encountered during software analysis. Use this skill when analyzing malware evasion techniques, when implementing anti-debugging protections for CTF challenges, when reverse engineering packed binaries, or when building security research tools that need to detect virtualized environments.★ 39.9k GitHub starsSkillBuild production Apache Airflow DAGs with best practicesApache Airflow DAG Patternswshobson/agents · by wshobsonBuild production Apache Airflow DAGs with best practices for operators, sensors, testing, and deployment. Use when creating data pipelines, orchestrating workflows, or scheduling batch jobs.★ 39.9k GitHub stars