| name | git-master |
| description | Advanced Git operations beyond basic add/commit/push — atomic commits, rebase, squash, fixup, blame, bisect, reflog, code archaeology (git log -S/-G), and worktree management. Use when the task mentions rebase, squash, bisect, blame, reflog, fixup, finding deleted code, tracing commit history, cleaning up a branch, or recovering lost work. |
| license | MIT |
| compatibility | opencode |
| metadata | {"audience":"developers","workflow":"git"} |
Git Master
Advanced Git patterns for when the basics aren't enough. Borrowed from
oh-my-openagent's git-master shared skill, adapted for pure prompt use.
When to use me
- Rebasing, squashing, or interactive history editing
- Finding when/where code was introduced or deleted (
git blame, git log -S/-G)
- Recovering lost commits or branches (
git reflog)
- Bisecting to find the commit that introduced a bug
- Cherry-picking or fixup workflows
- Managing stacked branches or worktrees
Atomic commits
One logical change per commit. Before committing, review with:
git add -p
git diff --cached
If the diff mixes unrelated changes, split them into separate commits.
Rewriting history (safety first)
Never rewrite shared/pushed history unless you own the branch and no one else
works on it. For personal branches:
git rebase -i HEAD~5
git rebase -i main
git reset --soft HEAD~3
git commit -m "feat: combined feature work"
git commit --fixup <sha>
git rebase -i --autosquash main
git commit --amend --no-edit
git commit --amend -m "better message"
Code archaeology
Find when code was introduced, changed, or deleted:
git blame path/to/file -L 40,60
git log -S "functionName" --oneline -- path/
git log -S "removed_feature" --patch
git log -G "TODO|FIXME" --oneline
git log --all --full-history -- "**/deleted-file.ts"
git show <commit>:path/to/file.ts
git show <commit>~1:path/to/file.ts
Recovering lost work
git reflog
git reflog show feature-branch
git checkout HEAD@{2}
git branch recovered HEAD@{5}
git reflog captures everything — rebases, resets, checkouts, even deleted
branches (until garbage collection). It's the ultimate undo.
Bisect: find the exact commit that broke things
git bisect start
git bisect bad HEAD
git bisect good v1.2.0
git bisect good
git bisect bad
git bisect reset
For automated bisect with a test script:
git bisect start HEAD v1.2.0
git bisect run npm test
Cherry-pick
git cherry-pick <sha>
git cherry-pick -x <sha>
git cherry-pick <sha1>..<sha3>
Stash work-in-progress
git stash push -m "WIP: half-done refactor"
git stash list
git stash pop
git stash apply stash@{1}
git stash drop stash@{1}
Worktrees: parallel branches without cloning
git worktree add ../feature-x feature-branch
git worktree list
git worktree remove ../feature-x
git worktree prune
Use worktrees when you need to work on two branches simultaneously (e.g., a
hotfix while mid-feature) without stashing or cloning.
Safety principles
- Never force-push shared branches —
git push --force-with-lease is the
safer alternative, but still confirm no one else is on the branch.
- Check authorship before amending —
git log -1 --format='%an %ae' to see
who wrote the last commit; don't amend commits authored by others.
- Verify before destructive operations — always run
git status and
git log --oneline -5 before a rebase or reset to confirm you're on the
right branch.
- Reflog is your safety net — if you mess up a rebase or reset,
git reflog
git checkout can recover almost anything.