| name | rebase |
| description | Rebase current work branch on latest main with intelligent conflict resolution. |
| inputs | {} |
| outputs | {"status":"string","conflicts_resolved":"array"} |
| dependencies | ["git"] |
| safety | Modifies branch history; uses --force-with-lease for safer force push. |
| steps | ["Store current branch name","Checkout main and pull latest","Return to work branch","Rebase on main","Resolve conflicts automatically with transparency","Force push with lease"] |
| tooling | ["git checkout, git pull, git rebase, git push --force-with-lease"] |
Rebase Skill
Overview
Automates rebasing the current work branch on the latest main, including intelligent conflict resolution and safe force pushing.
Usage
WORK_BRANCH=$(git branch --show-current)
if [ "$WORK_BRANCH" == "main" ]; then
echo "Error: Cannot rebase main onto itself"
exit 1
fi
git checkout main
git pull
git checkout $WORK_BRANCH
git rebase main
git push --force-with-lease origin $WORK_BRANCH
Conflict Resolution Strategy
When conflicts occur during rebase:
-
List conflicted files: git diff --name-only --diff-filter=U
-
For each conflicted file, analyze and resolve:
- Non-overlapping changes: Keep both (manual merge)
- Identical changes: Accept either version
- Overlapping changes: Default to accepting incoming (main) changes
- Rationale: Main represents the agreed-upon state
- Always warn when using this strategy
-
Resolution commands:
git checkout --theirs <file>
git checkout --ours <file>
git add <file>
-
Continue rebase: git rebase --continue
-
Repeat until complete
Transparency Reporting
Always report:
- List of files with conflicts
- Resolution strategy used for each file
- Any files requiring manual review
- Final rebase summary:
git log --oneline main..HEAD
Safety
- Validates: Never rebase main onto itself
- Uses --force-with-lease: Prevents overwriting unexpected remote changes
- Abort on failure: If unable to auto-resolve, run
git rebase --abort
- Transparency: Always report resolution decisions made
Abort Strategy
If automatic conflict resolution fails:
git rebase --abort
Then report to user with suggestion to resolve manually via git rebase -i main
Common Use Cases
- Rebase feature branch before creating PR (clean history)
- Incorporate latest main changes into work branch
- Resolve conflicts with main after updates
- Clean up commit history before merge
Safety Notes
- Changes branch history (commits will have new SHAs)
- Requires force push (uses safer
--force-with-lease)
- May conflict with ongoing work if others are on the same branch
- Review changes after complex conflict resolution