# Rebase Branch onto Main

> Rebase the current feature branch onto origin/main and resolve conflicts.

- Skill: `tools-only/rebase-branch-onto-main` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add tools-only/rebase-branch-onto-main`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tools-only/rebase-branch-onto-main/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tools-only (https://skillmd.com/u/tools-only)
- Updated: 2026-09-29
- Page: https://skillmd.com/skills/tools-only/rebase-branch-onto-main

---


# Rebase Branch onto Main

Rebase the current feature branch onto `origin/main` and resolve conflicts.

## Pre-flight Checks (Abort if any fail)

1. Working directory is clean (`git status` shows no uncommitted changes)
2. Not already in rebase/merge state
3. Not on main/master branch
4. Remote origin exists

## Workflow

1. `git fetch origin`
2. `git rebase origin/main`
3. For each conflict:
   - Apply resolution strategy (see below)
   - Verify no conflict markers remain
   - `git add <file>` or `git rm <file>`
   - `git rebase --continue`
4. Run code checks: `mcp__code-checker__run_pytest_check`, `mcp__code-checker__run_pylint_check`, `mcp__code-checker__run_mypy_check`
5. Fix any issues from merge
6. Report summary and ask for user confirmation
7. `git push --force-with-lease`

## Conflict Resolution Strategies

| File Type | Strategy |
|-----------|----------|
| 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)

1. Any unexpected error - abort, report full error
2. Binary file conflict - abort, cannot auto-resolve
3. Unknown file type - abort, no safe strategy
4. Conflict markers remain after resolution - abort
5. Same file conflicts 3+ times - abort
6. Code quality fails after 2 fix attempts - abort
7. Any other unexpected situation - abort, suggest manual intervention

On abort: run `git rebase --abort`, report which rule triggered, suggest next steps.

