| name | rebase |
| description | Rebase the current branch onto a target branch and walk through conflict resolution. Use when the user wants to rebase, sync with main, or resolve rebase conflicts. |
| argument-hint | ["target"] |
| allowed-tools | Bash(git fetch:*), Bash(git rebase:*), Bash(git log:*), Bash(git add:*), Bash(git status:*), Read, Edit |
Rebase the current branch.
Arguments: $ARGUMENTS
Behavior
- No arguments: fetch origin, update local default branch, rebase onto it
- "origin": fetch origin, update local default branch, rebase onto it
- "origin/branch": fetch origin, update local branch, rebase onto it
- "branch": fetch origin, update local branch, rebase onto it
Steps
- Determine the default branch by running:
git remote show origin | awk '/HEAD branch/ {print $NF}'
- Parse arguments:
- No args → target branch is
- Contains "/" (e.g., "origin/develop") → extract branch name after "/"
- Just "origin" → target branch is
- Anything else → target branch is the argument
- Run:
git fetch origin
- Run:
git rebase <branch> (using local branch, not origin/branch)
- If conflicts occur, handle them carefully (see below)
- Continue until rebase is complete
Handling conflicts
- BEFORE resolving any conflict, understand what changes were made to each conflicting file in the target branch
- For each conflicting file, run
git log -p -n 3 <target> -- <file> to see recent changes to that file in the target branch
- The goal is to preserve BOTH the changes from the target branch AND our branch's changes
- After resolving each conflict, stage the file and continue with
git rebase --continue
- If a conflict is too complex or unclear, ask for guidance before proceeding
Output
IMPORTANT: Be silent during execution. Do not narrate your actions or explain what you're doing.
When complete, output ONLY a compact summary in this exact format:
Rebased N commits onto <target>
[If conflicts:]
- <file>: <one line describing resolution>
- <file>: <one line describing resolution>
Nothing else. No explanations, no status updates, no tool output.