Skills · Coding

Git Advanced Workflows

Unverified26/40

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.

Originally by wshobson · MIT

Claude CodePartialHas SKILL.md but declares no allowed-tools — Claude Code will ask for permission each time
Cursor·UnknownWe have not crawled the repo tree, so we will not guess
Codex·UnknownWe have not crawled the repo tree, so we will not guess
Gemini CLI·UnknownThe spec defines no detection rule for Gemini
Copilot·UnknownWe have not crawled the repo tree, so we will not guess
npx agentalley add git-advanced-workflows

This command does not work yet — the CLI is still being built. Until then, use Raw in the reader below to take the file.

Who is stuck, and on what

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.

The whole source

No sign-in, no blur, nothing truncated
git-advanced-workflows/SKILL.md199 lines4.9 KBRawView on GitHub
Frontmatter — 2 properties
namegit-advanced-workflows
descriptionMaster 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.
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---A5No allowed-tools declared — no way to tell what this skill may touch
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-branchA1Throws away uncommitted changes
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^A1Throws away uncommitted changes
194 
195# Recover deleted branch (within 90 days)
196git reflog
197git branch recovered-branch abc123
198```
199 

Reviews

Installed this one?Write the first review and take the Trailblazer badge.

Reviews only open after a real install, so this is empty — and we leave it empty rather than invent one.

Alternatives

Also in Coding