Rebase Branch onto Base Branch
First Step
Call mcp__mcp-workspace__git with command "status" before doing anything else.
Rebase the current feature branch onto its base branch and resolve conflicts.
Core philosophy: Main is the source of truth. The feature branch adapts to main. For source code conflicts, preserve main's improvements and rework the feature branch code to fit.
Note on --ours/--theirs during rebase: --ours = main (the branch being rebased onto), --theirs = feature branch commits being replayed.
If the rebase becomes complex, suggest switching to cherry-picking as an alternative approach.
Determine Base Branch
Call mcp__mcp-workspace__get_base_branch to detect the correct base branch. Use the returned branch name in subsequent git commands.
Base Branch Confirmation
If the base branch is not main or master, ask the user to confirm before proceeding. Display the detected base branch and wait for explicit approval.
Pre-flight Checks (Abort if any fail)
- Working directory is clean (no uncommitted changes)
- Not already in rebase/merge state
- Not on main/master branch
- Remote origin exists
pr_info/does not exist on the base branch — if it does, abort with error:"pr_info/ exists on <BASE_BRANCH>. This folder should only exist on feature branches. Check your branch setup."
Workflow
- Call
mcp__mcp-workspace__gitwith command"fetch"and args["origin"] git rebase origin/${BASE_BRANCH}- For each conflict:
- If file is under
pr_info/: auto-resolve withgit checkout --theirs <file>(keep feature branch version), thengit add <file>— no user input needed - For all other files: resolve manually, preserving main's improvements; rework feature branch changes to fit
- Verify no conflict markers remain
git add <file>git rebase --continue
- If file is under
- Run code checks:
mcp__mcp-tools-py__run_pytest_check,mcp__mcp-tools-py__run_pylint_check,mcp__mcp-tools-py__run_mypy_check - Fix any issues from merge
- Report summary and ask for user confirmation
git push --force-with-lease
Conflict Resolution Strategies
| File Type | Strategy |
|---|---|
pr_info/ files |
Auto-resolve with --theirs (keep feature branch version) |
Code files (.py, .js, etc.) |
Keep both sides, merge imports |
| Test files | Keep all tests from both sides |
| Config files | Merge additively, prefer HEAD for same keys |
Lockfiles (*-lock.json, *.lock) |
Accept theirs (--theirs), notify user to regenerate after rebase |
Abort Rules (in priority order)
- Any unexpected error - abort, report full error
- Binary file conflict - abort, cannot auto-resolve
- Conflict markers remain after resolution - abort
- Same file conflicts 3+ times - abort
- Code quality fails after 2 fix attempts - abort
- Any other unexpected situation - abort, suggest manual intervention
On abort: run git rebase --abort, report which rule triggered, suggest next steps.