1- # Restack
2-
3- Use when user asks to "restack", "resolve conflicts", "gt restack", or mentions restack conflicts. Guides through gt restack conflicts with intelligent diagnostics and resolution. (project)
1+ ---
2+ name : restack
3+ description : Use when user asks to "restack", "resolve conflicts", "gt restack", or mentions restack conflicts. Guides through gt restack conflicts with intelligent diagnostics and resolution.
4+ allowed-tools : Bash(gt restack:*), Bash(gt continue:*), Bash(git show:*), Bash(git diff:*), Bash(git log:*), Bash(git ls-tree:*), Bash(pnpm install:*), Bash(git status:*), Bash(gt log:*), Bash(rm pnpm-lock.yaml), Bash(gt add -A:*),
5+ ---
46
57<critical >
68- ALWAYS check current state first (supports both: starting fresh or mid-conflict)
@@ -21,12 +23,14 @@ git status
2123```
2224
2325** Check for** :
26+
2427- "rebase in progress"
2528- "You are currently rebasing"
2629- "Unmerged paths"
2730- "both modified:" or other conflict indicators
2831
2932** Outcomes** :
33+
3034- Already in conflict (user ran ` gt restack ` manually) → Skip to step 3 (Gather Diagnostics)
3135- Clean state → Proceed to step 2 (Run Restack)
3236
@@ -37,6 +41,7 @@ gt restack
3741```
3842
3943** Outcomes** :
44+
4045- Success → Acknowledge and exit
4146- Conflicts → Proceed to step 3
4247
@@ -61,11 +66,13 @@ git diff <file>
6166### 3. Explain Conflict Type
6267
6368** Simple conflict** (lockfile-only):
69+
6470- Only ` pnpm-lock.yaml ` in unmerged files
6571- Explain: Lockfile is generated content, safe to regenerate
6672- Propose: ` pnpm install && gt add -A && gt continue `
6773
6874** Complex conflict** (multi-file):
75+
6976- Multiple files in unmerged files
7077- Explain each file's conflict
7178- Guide through resolution strategy
@@ -75,6 +82,7 @@ git diff <file>
7582#### Simple Conflict Resolution
7683
7784Use AskUserQuestion:
85+
7886```
7987question: "Only pnpm-lock.yaml is conflicted. Regenerate and continue?"
8088header: "Simple Resolution"
@@ -86,6 +94,7 @@ options:
8694```
8795
8896If confirmed → Execute → Check output of ` gt continue ` :
97+
8998- Another conflict → Loop back to step 3 (Gather Diagnostics)
9099- Success message → Proceed to step 6 (Success & Reminder)
91100
@@ -94,16 +103,19 @@ If confirmed → Execute → Check output of `gt continue`:
94103For each non-lockfile conflict:
95104
96105** a) Show the conflict** :
106+
97107``` bash
98108git diff < file>
99109```
100110
101111** b) Explain the conflict** (extract from diff):
112+
102113- What changed in base (HEAD)
103114- What changed in branch (incoming)
104115- Why it conflicts
105116
106117** c) Ask resolution strategy** using AskUserQuestion:
118+
107119```
108120question: "How to resolve <file>?"
109121header: "Resolution"
@@ -119,17 +131,20 @@ options:
119131```
120132
121133** d) Execute choice** :
134+
122135- ` --theirs ` : ` git checkout --theirs <file> `
123136- ` --ours ` : ` git checkout --ours <file> `
124137- Manual: Wait for user confirmation
125138- Show original: Display and ask again
126139
127140** e) After all non-lockfile conflicts resolved** :
141+
128142``` bash
129143pnpm install && gt add -A && gt continue
130144```
131145
132146** f) Check output of ` gt continue ` ** :
147+
133148- Another conflict → Loop back to step 3 (Gather Diagnostics)
134149- Success message → Proceed to step 6 (Success & Reminder)
135150
@@ -138,6 +153,7 @@ pnpm install && gt add -A && gt continue
138153If diagnostics show "broken lockfile" warning:
139154
140155Use AskUserQuestion:
156+
141157```
142158question: "Lockfile is corrupted. Delete and regenerate?"
143159header: "Broken Lockfile"
@@ -149,6 +165,7 @@ options:
149165```
150166
151167After executing choice, check output of command:
168+
152169- Another conflict → Loop back to step 3 (Gather Diagnostics)
153170- Success message → Proceed to step 6 (Success & Reminder)
154171
@@ -170,36 +187,42 @@ Note: Always use --force-with-lease for safety
170187## Quick Reference
171188
172189** Simple lockfile conflict** :
190+
173191``` bash
174192pnpm install && gt add -A && gt continue
175193```
176194
177195** Multiple files conflicted** :
196+
178197``` bash
179198git diff < file> # Inspect
180199git checkout --ours/--theirs < file> # Resolve
181200pnpm install && gt add -A && gt continue
182201```
183202
184203** Broken lockfile** :
204+
185205``` bash
186206rm pnpm-lock.yaml
187207pnpm install && gt add -A && gt continue
188208```
189209
190210** Cancel restack** :
211+
191212``` bash
192213gt abort
193214```
194215
195216## Resolution Strategy Guide
196217
197218** When to use ` --theirs ` (accept main's version)** :
219+
198220- Style/formatting conflicts (e.g., quoted vs unquoted YAML)
199221- Configuration files where consistency with main matters
200222- Files you didn't intentionally change
201223
202224** When to use ` --ours ` (keep branch's version)** :
225+
203226- Your branch added dependencies (e.g., pnpm-workspace.yaml)
204227- Feature changes you need to preserve
205228- Files where your changes are the whole point
0 commit comments