# Gt:restack

> Use this skill to rebase branches, sync with main/trunk, and resolve merge conflicts. REPLACES git rebase — never use it directly. Triggers: 'restack', 'rebase', 'rebase on main', 'sync with main', 'update stack', 'resolve conflicts', 'branches out of date'.

- Skill: `luan/gt-restack` (Agent Skill)
- Install (CLI): `npx skillmds@latest add luan/gt-restack`
- Raw SKILL.md: https://api.skillmd.com/api/skills/luan/gt-restack/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: luan (https://skillmd.com/u/luan)
- Updated: 2026-09-10
- Page: https://skillmd.com/skills/luan/gt-restack

---


# Restack

Rebase Graphite stack onto updated parents and resolve any merge conflicts.

## Steps

1. **Restack**: `gt restack 2>&1`

2. **If clean**: report which branches were restacked. Done.

3. **If conflicts**: loop until resolved —
   a. Read each conflicted file **in full** before editing b. Identify **all** conflict markers (`<<<<<<<`, `=======`, `>>>>>>>`) in the file c. Resolve **every** conflict region in a **single edit** — never leave partial markers d. `git add <file>` each resolved file
   e. `gt continue 2>&1`
   f. If new conflicts appear (next branch in stack), repeat from (a)

4. **Report**: list branches restacked, conflicts resolved, any issues.

## Conflict Resolution Rules

- Read the full file first. Count all `<<<<<<<` markers. Resolve all of them in one pass.
- Take the **semantically correct** merge: understand what both sides changed, combine intent.
- For renames/refactors: apply the rename to the newer code from the child branch.
- After editing, verify no conflict markers remain: `rg -c '<<<<<<<' <file>` before `git add`.
- If a conflict is ambiguous and you can't determine the right resolution, `gt abort` and report to the user.

