# git-rebase

Walks an agent through a rebase and settles conflicts commit by commit, leaving unrelated work alone. Useful when a branch has fallen behind its base.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 376 installs · ★ 643
- Author: Pedro Nauck
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/pedronauck/skills/tree/HEAD/skills/mine/git-rebase/SKILL.md
- Updated: 2026-10-20
- HTML: https://affpapa.org/en/nevibecode/skills/git-rebase

## What it does

The skill runs in steps. The agent checks status, the current branch and the target, sees whether a rebase is already running, and keeps uncommitted edits where they are. No auto-stash, no `reset`, no `checkout`; when the tree is messy, it works in a separate checkout.

Before rewriting anything valuable, the agent notes HEAD and makes a backup ref with `scripts/pre-rebase-backup.sh`. A plain rebase onto the requested target is the norm. Squashing or reordering happens only on your request, not because the branch has many commits. Each conflict gets its own pass: during a rebase `ours` means the target plus the commits already replayed, `theirs` is the one being replayed now. The agent reads the changed APIs instead of taking a side wholesale, so the security and compatibility contracts survive.

Publishing a rewritten branch happens only if you already allowed it, and it goes through `--force-with-lease`. Should that lease fail, the agent inspects the new remote commits rather than switching to an unconditional force. Merge-commit flows, cherry-picking and repository setup are outside its scope.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add pedronauck/skills --skill git-rebase -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/git-rebase/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/git-rebase/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add pedronauck/skills --skill git-rebase -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/git-rebase/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add pedronauck/skills --skill git-rebase -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/git-rebase/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install pedronauck/skills git-rebase
```

2. **Manually: put the files in place**
- File: `.github/skills/git-rebase/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add pedronauck/skills --skill git-rebase -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/pedronauck/skills --path skills/mine/git-rebase
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/git-rebase/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add pedronauck/skills --skill git-rebase -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/pedronauck/skills/tree/HEAD/skills/mine/git-rebase/SKILL.md

## When to use it
- Move a branch onto a newer base without losing either side
- Work through a conflict between the replayed commit and earlier ones
- Take a backup ref before history is rewritten
- Push a rewritten branch without clobbering others' commits
- Check the resulting diff and test the affected behaviour

## Example prompts
- Rebase this branch onto `main` and handle conflicts one at a time
- Move `feature/auth` onto `origin/main` and keep my uncommitted edits
- Push the branch after the rebase using `--force-with-lease`

## Similar
- [triage](https://affpapa.org/en/nevibecode/skills/triage.md) — skill · 990453 installs
- [code-review](https://affpapa.org/en/nevibecode/skills/code-review.md) — skill · 789521 installs
- [implement](https://affpapa.org/en/nevibecode/skills/implement.md) — skill · 774700 installs
- [git-guardrails-claude-code](https://affpapa.org/en/nevibecode/skills/git-guardrails-claude-code.md) — skill · 499069 installs
- [setup-pre-commit](https://affpapa.org/en/nevibecode/skills/setup-pre-commit.md) — skill · 489289 installs
- [scaffold-exercises](https://affpapa.org/en/nevibecode/skills/scaffold-exercises.md) — skill · 480196 installs

From the same set: [pedronauck/skills](https://affpapa.org/en/nevibecode/by/pedronauck/skills.md) — 18 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
