Imported from IcodeNet/agent-skills (
skills/rebase-onto-main/SKILL.md). Install upstream withnpx skills add IcodeNet/agent-skills --skill rebase-onto-main. Copyright stays with the author.
Rebase Onto Main
Rebase the current branch onto the latest main safely.
-
Branch + cleanliness checks
- Run
git branch --show-current; abort if onmain/master. - Run
git status --short. - If the working tree is dirty, stop and ask whether to commit or stash first.
- Run
-
Fetch latest main
- Run
git fetch origin main. - If the default branch isn't
main, detect it (git remote show origin) and use that instead throughout.
- Run
-
Rebase
- Run
git rebase origin/main.
- Run
-
Conflict handling (mandatory)
- If a conflict occurs:
- Run
git status --shortand report conflicted files. - Stop and ask the user whether to continue resolving, abort (
git rebase --abort), or take a narrower scope.
- Run
- If a conflict occurs:
-
Post-rebase verification
- Run
git status. - Run
git log --oneline -5for a quick verification summary. - If the branch was previously pushed, note that the next push requires
--force-with-lease— never plain--force.
- Run