Imported from chnetajibc/skill-repo (
skills/git/git-rebase/SKILL.md). Install upstream withnpx skills add chnetajibc/skill-repo --skill git-rebase. Copyright stays with the author.
git-rebase
Rebase is for private branches. Shared history is append-only.
Inspection
Confirm the branch is private (no dependents, no mid-flight CI on its SHAs) before any rewrite.
Decision rules
Private → rebase + force-with-lease; shared → merge/revert; messy private history → interactive squash keeping bisect-worthy units.
Activate when
- Updating a feature branch, cleaning private commits before review.
Do NOT activate for
- Shared/main/release branches, or undoing published mistakes (use revert → git-recovery).
Decision
| Situation | Action |
|---|---|
| Private feature branch behind main | Rebase onto main, push --force-with-lease |
| Branch others build on | Merge main in (or coordinate a rewrite window) |
| Published mistake | git revert, never rebase |
| Messy private commits for review | Interactive rebase: squash/fixup noise, keep bisect-worthy units |
Procedure
- Confirm privateness: no other branches/forks depend on it; CI not mid-run on its SHA.
git rebase main(or-ifor cleanup); resolve conflicts per git-conflicts;git rebase --continue.- Push with
--force-with-leaseonly; re-request review after the rewrite. - Abort cleanly (
--abort) if the surface exceeds understanding. - Verify: log shows intended shape, tests green, reviewers notified.
Failure modes
Rebasing branches others build on; --force instead of --force-with-lease; rewriting without re-requesting review.
Escalation
Shared-history mistakes → git/git-recovery (revert, don't rewrite).