Interactive rebase-onto-main workflow with conflict resolution. Use when rebasing a feature branch onto main, resolving merge conflicts, or when the user asks to pull in the latest main.
You are helping a human rebase their feature branch onto the latest origin/main. This protocol walks through the rebase, presents conflicts one at a time, and lets the human choose the resolution.
Scope: This is a git workflow — fetch the latest main, rebase your commits on top, and walk through any conflicts one at a time with clear recommendations.
main.git status must be clean). If dirty, ask the human to commit or stash first.git-commitgit fetch origin main
git rebase origin/main
If the rebase completes cleanly (no conflicts), skip to Phase 3: Verify.
If conflicts occur, git will pause. Proceed to Phase 2.
A rebase replays your commits one at a time on top of main. Each commit that conflicts produces a separate rebase step. For each step:
# Show which commit is being replayed
git log --oneline -1 REBASE_HEAD
# List files with conflicts
git diff --name-only --diff-filter=U
Tell the human: "Replaying commit <hash> <subject>. The following files have conflicts: ..."
For each conflicting file, read the file and find the conflict markers (<<<<<<<, =======, >>>>>>>). For each conflict hunk:
Show both sides clearly labeled:
origin/main — what landed while you were workingProvide context: Read 10–20 lines above and below the conflict to understand intent. If the conflict involves imports, check what symbols are actually used in the file. If it involves logic changes, explain what each side does differently.
Recommend a resolution with reasoning. Use the heuristics table below to guide your recommendation. Present one of:
Ask the human to choose. Never auto-resolve without confirmation. Present it as a structured choice.
After the human chooses:
git add <file># Verify no remaining conflicts
git diff --name-only --diff-filter=U
# Continue the rebase
git rebase --continue
After the rebase completes:
# Confirm we're on the feature branch, not detached
git branch --show-current
# Show the branch's commits on top of main
git log --oneline origin/main..HEAD
# Confirm working tree is clean
git status
Tell the human the rebase is complete and show them the commit log. Highlight if any commits were dropped or squashed.
If the branch performed a migration or rename (e.g., replacing toaster with notifications), grep the full source tree for the old pattern:
grep -r "OLD_PATTERN" src/ --include="*.ts" --include="*.tsx"
Any hits in active code (not comments) are bugs introduced by the rebase bringing in main's code that predates the migration. Fix them with a new commit before proceeding.
This is mandatory, not optional. Run the project's test suite and report results:
pnpm test
If new failures appeared that weren't present before the rebase, they are rebase artifacts and must be fixed before pushing.
If the project has a dev server, start it and confirm the app loads without a white screen or console errors:
pnpm dev:mock # or pnpm dev
This catches runtime crashes from missing imports or undefined references that tests may not cover.
Note: Uncommitted changes to tracked files (e.g., dev-only config tweaks in mock routes) are silently overwritten during rebase. If you had local modifications before starting, verify those files after the rebase completes.
The human must force-push since rebase rewrites history:
git push --force-with-lease
Never run force-push without the human's explicit approval. Present the command and wait for confirmation. --force-with-lease is safer than --force because it refuses to push if someone else pushed to the remote branch since your last fetch.
When recommending a resolution, use these heuristics:
| Scenario | Recommendation |
|---|---|
| Main updated a dependency version, your branch didn't touch it | Pick main |
| Both sides added new imports | Merge both (keep all imports) |
| Main refactored a function your branch also modified | Read both carefully — usually rewrite to apply your change on top of main's refactored version |
| Both sides modified the same lines | Stop and ask — this requires human judgment |
| Conflict is in generated files (lock files, etc.) | Regenerate after rebase completes |
| Conflict is in a file your commit didn't intentionally change | Pick main |
| Branch performed a codebase-wide migration and main added new code using the old pattern | Rewrite — apply the migration to main's new code. After the rebase completes, sweep the full tree for the old pattern (step 3a). |
If the rebase gets into a bad state or the human wants to start over:
git rebase --abort
This restores the branch to its pre-rebase state with no side effects. Always mention this option if the human seems uncertain.
git rebase --continuegit rebase --abort is always safegit-commit