Restack
Rebase gh-stack branches onto updated parents and resolve merge conflicts.
Modes
| Mode | Command | When |
|---|---|---|
| Full sync | gh stack sync |
Default — fetch, rebase, push, sync PR state |
| Rebase only | gh stack rebase |
User says "rebase" / "restack" without push |
| Upstack only | gh stack rebase --upstack |
After mid-stack changes |
Steps
Sync:
gh stack sync 2>&1If clean: report which branches were rebased. Done.
If conflicts (exit code 3): run
gh stack rebasethen loop until resolved — a. Read each conflicted file in full before editing b. Identify all conflict markers (<<<<<<<,=======,>>>>>>>) c. Resolve every conflict region in a single edit d.git add <file>each resolved file e.gh stack rebase --continue 2>&1f. If new conflicts appear, repeat from (a)Push after rebase:
gh stack push 2>&1Report: list branches rebased, 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.
- After editing, verify no conflict markers remain:
rg -c '<<<<<<<' <file>beforegit add. - If a conflict is ambiguous,
gh stack rebase --abortand report to the user.