git-advanced-workflows
1
总安装量
1
周安装量
#49033
全站排名
安装命令
npx skills add https://github.com/mileycy516-stack/skills --skill git-advanced-workflows
Agent 安装分布
mcpjam
1
claude-code
1
replit
1
junie
1
windsurf
1
zencoder
1
Skill 文档
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 (rebase)
- Applying specific commits across branches (cherry-pick)
- Finding commits that introduced bugs (bisect)
- Working on multiple features simultaneously (worktrees)
- Recovering from Git mistakes or lost commits (reflog)
- Synchronizing diverged branches
Workflow
- Context: Are you cleaning history, recovering lost work, or isolating a bug?
- Safety: Always create a backup branch before destructive operations (
git branch backup-before-rebase). - Execute: Use the specific command (rebase -i, bisect, reflog).
- Verify: Check log/tests to ensure integrity.
- Push: If history changed, use
--force-with-lease.
Instructions
1. Interactive Rebase (The History Editor)
Use to squash typos, reword messages, or reorder commits.
git rebase -i HEAD~5
# Commands: pick, reword, edit, squash, fixup, drop
- Autosquash:
git commit --fixup HEAD->git rebase -i --autosquash main.
2. Cherry-Picking (The Sniper)
Apply specific commits to another branch without merging.
git cherry-pick abc1234
git cherry-pick abc1234..def5678 # Range
git cherry-pick -n abc1234 # Stage only (no commit)
3. Git Bisect (The Bug Hunter)
Binary search to find the exact commit that broke something.
git bisect start
git bisect bad # Current is broken
git bisect good v1.0.0 # v1.0.0 was working
# Git checks out middle commit... you test...
git bisect good # or bad
# Repeat until found
git bisect reset
4. Worktrees (The Multitasker)
Check out multiple branches in parallel folders. No more stash/switch ping-pong.
git worktree add ../feature-folder feature/new-stuff
# Work there...
git worktree remove ../feature-folder
5. Reflog (The Time Machine)
Recover “lost” commits after a hard reset or delete.
git reflog
# Find the hash BEFORE you messed up (e.g., abc1234)
git reset --hard abc1234
# Or restore a deleted branch
git branch recovered-branch abc1234