Rebase on Main
Rebase the current branch onto the latest origin/main, resolving any merge conflicts interactively.
Process
Step 1: Pre-flight checks
- •Check for uncommitted changes - if any exist, stop and ask the user to commit or stash them
- •Show the current branch name
Step 2: Choose rebase target
- •Prompt the user to choose between:
- •
origin/main(remote - default) - Use when you want to rebase against the latest remote changes - •
main(local) - Use when you have local merged changes that haven't been pushed yet
- •
Step 3: Fetch and attempt rebase
- •If rebasing against
origin/main, rungit fetch origin main - •Run
git rebase <chosen-target> - •If rebase succeeds with no conflicts, report success and show the push command
Step 4: Resolve conflicts (if any)
For each conflicted file:
- •Show the conflict - Run
git diff --name-only --diff-filter=Uto list conflicted files - •Read and understand - Read each conflicted file to see the conflict markers (
<<<<<<<,=======,>>>>>>>) - •Explain the conflict - Tell the user what both sides are trying to do:
- •"HEAD (your branch) is adding/changing X"
- •"origin/main is adding/changing Y"
- •Propose a resolution - Suggest how to combine the changes (usually keeping both)
- •Ask for approval - Use AskUserQuestion to confirm the resolution approach before editing
- •Apply the fix - Edit the file to resolve the conflict, removing all conflict markers
- •Verify syntax - For Python files, run
uv run python -m py_compile <file> - •Stage the file - Run
git add <file>
Repeat for each conflicted file.
Step 5: Continue the rebase
After all conflicts are resolved:
- •Run
git rebase --continue - •If more conflicts appear (from subsequent commits), repeat Step 4
- •Continue until rebase completes
Step 6: Final summary
Show:
- •"Rebase completed successfully!"
- •Number of conflicts resolved
- •The command to push:
git push --force-with-lease
Important notes
- •Never force-push automatically - always let the user do this manually
- •Always ask before resolving ambiguous conflicts - if the intent isn't clear, ask
- •Preserve both changes when possible - most conflicts in this project are additive (both sides adding new code)
- •Check Python syntax after each resolution - catch errors early