| name | rebase-main |
| description | Rebases the current branch on the latest default branch (main, master, etc.), resolving any merge conflicts automatically. Detects the default branch and remote, fetches latest, performs rebase, and handles conflicts file-by-file. |
Rebase on Default Branch
Rebases the current branch onto the latest default branch, resolving conflicts along the way.
Process
1. Pre-flight Checks
2. Fetch Latest Default Branch
git fetch <remote> <default-branch>
3. Start Rebase
git rebase <remote>/<default-branch>
If the rebase completes without conflicts, report success with the number of commits replayed and exit.
4. Resolve Conflicts (loop until rebase completes)
When conflicts occur, for each conflicted file:
- Run
git diff --name-only --diff-filter=U to list all conflicted files.
- For each conflicted file:
a. Read the file to see the conflict markers (
<<<<<<<, =======, >>>>>>>).
b. Understand both sides:
- ours (during rebase) = the commit being replayed (your branch's changes)
- theirs (during rebase) = the default branch (the new base)
c. Resolve the conflict following the rules below.
d. Stage the resolved file with
git add <file>.
- After all files in the current step are resolved, continue the rebase:
git rebase --continue
- If new conflicts arise on subsequent commits, repeat from step 1.
5. Post-rebase Verification
After the rebase completes:
- Run
git log --oneline <remote>/<default-branch>..HEAD to show the replayed commits.
- Report the result to the user.
Conflict Resolution Rules
General Rule
Default to the default branch (theirs during rebase) as the source of truth, then re-apply local branch changes on top only when they can be preserved cleanly.
- Preserve the default branch's implementation, architecture, and public behavior.
- Re-apply local changes only when they are additive and don't conflict with the intent of the default branch's changes.
- If both sides made meaningful but incompatible changes, stop and ask the user.
Auto-generated Files
For files that are auto-generated (e.g., schema.graphql, Prisma client, Apollo codegen output):
- Accept the default branch version entirely.
- After the rebase completes, re-run the relevant codegen commands to incorporate local changes.
Lock Files & Dependencies
For bun.lock, package-lock.json, yarn.lock, or similar:
- Accept the default branch version.
- After the rebase, re-run the package manager install to regenerate the lock file if local changes added/changed dependencies.
When to Stop and Ask
- Conflicting business logic where both sides made intentional, incompatible changes.
- Deleted vs. modified conflicts where the intent is unclear.
- More than 20 conflicted files in a single rebase step (likely a sign of divergence that needs human judgment).
Output
When complete, report:
- Total commits replayed
- Files that had conflicts and how they were resolved
- Any codegen or install commands that were re-run
- Any conflicts that required user input