Skip to content

Commit 28629a8

Browse files
committed
fix(worktree-add): prevent incorrect upstream tracking to base branch
1 parent 443ebb0 commit 28629a8

5 files changed

Lines changed: 18 additions & 12 deletions

File tree

.claude/commands/worktree-add.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,9 @@ Uncommitted changes: `git status --short`
212212
<description>Create the worktree</description>
213213
<option_a_new_branch>
214214
<condition>Remote branch does NOT exist</condition>
215-
<command>git worktree add ${parent_path}/${branch_name} -b ${branch_name} ${base_branch}</command>
216-
<example>git worktree add ../fix/issue-123-main-content-area-visually-clipped -b fix/issue-123-main-content-area-visually-clipped main</example>
215+
<command>git worktree add ${parent_path}/${branch_name} -b ${branch_name} --no-track ${base_branch}</command>
216+
<example>git worktree add ../fix/issue-123 -b fix/issue-123 --no-track origin/main</example>
217+
<note>--no-track prevents git from setting upstream to base_branch (which would make git push target main!)</note>
217218
</option_a_new_branch>
218219
<option_b_existing_branch>
219220
<condition>Remote branch EXISTS</condition>

downloads/with-beads/worktree-add.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,9 @@ Uncommitted changes: `git status --short`
212212
<description>Create the worktree</description>
213213
<option_a_new_branch>
214214
<condition>Remote branch does NOT exist</condition>
215-
<command>git worktree add ${parent_path}/${branch_name} -b ${branch_name} ${base_branch}</command>
216-
<example>git worktree add ../fix/issue-123-main-content-area-visually-clipped -b fix/issue-123-main-content-area-visually-clipped main</example>
215+
<command>git worktree add ${parent_path}/${branch_name} -b ${branch_name} --no-track ${base_branch}</command>
216+
<example>git worktree add ../fix/issue-123 -b fix/issue-123 --no-track origin/main</example>
217+
<note>--no-track prevents git from setting upstream to base_branch (which would make git push target main!)</note>
217218
</option_a_new_branch>
218219
<option_b_existing_branch>
219220
<condition>Remote branch EXISTS</condition>

downloads/without-beads/worktree-add.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,9 @@ Uncommitted changes: `git status --short`
210210
<description>Create the worktree</description>
211211
<option_a_new_branch>
212212
<condition>Remote branch does NOT exist</condition>
213-
<command>git worktree add ${parent_path}/${branch_name} -b ${branch_name} ${base_branch}</command>
214-
<example>git worktree add ../fix/issue-123-main-content-area-visually-clipped -b fix/issue-123-main-content-area-visually-clipped main</example>
213+
<command>git worktree add ${parent_path}/${branch_name} -b ${branch_name} --no-track ${base_branch}</command>
214+
<example>git worktree add ../fix/issue-123 -b fix/issue-123 --no-track origin/main</example>
215+
<note>--no-track prevents git from setting upstream to base_branch (which would make git push target main!)</note>
215216
</option_a_new_branch>
216217
<option_b_existing_branch>
217218
<condition>Remote branch EXISTS</condition>

scripts/__tests__/__snapshots__/downloads.test.ts.snap

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2751,8 +2751,9 @@ Uncommitted changes: \`git status --short\`
27512751
<description>Create the worktree</description>
27522752
<option_a_new_branch>
27532753
<condition>Remote branch does NOT exist</condition>
2754-
<command>git worktree add \${parent_path}/\${branch_name} -b \${branch_name} \${base_branch}</command>
2755-
<example>git worktree add ../fix/issue-123-main-content-area-visually-clipped -b fix/issue-123-main-content-area-visually-clipped main</example>
2754+
<command>git worktree add \${parent_path}/\${branch_name} -b \${branch_name} --no-track \${base_branch}</command>
2755+
<example>git worktree add ../fix/issue-123 -b fix/issue-123 --no-track origin/main</example>
2756+
<note>--no-track prevents git from setting upstream to base_branch (which would make git push target main!)</note>
27562757
</option_a_new_branch>
27572758
<option_b_existing_branch>
27582759
<condition>Remote branch EXISTS</condition>
@@ -5715,8 +5716,9 @@ Uncommitted changes: \`git status --short\`
57155716
<description>Create the worktree</description>
57165717
<option_a_new_branch>
57175718
<condition>Remote branch does NOT exist</condition>
5718-
<command>git worktree add \${parent_path}/\${branch_name} -b \${branch_name} \${base_branch}</command>
5719-
<example>git worktree add ../fix/issue-123-main-content-area-visually-clipped -b fix/issue-123-main-content-area-visually-clipped main</example>
5719+
<command>git worktree add \${parent_path}/\${branch_name} -b \${branch_name} --no-track \${base_branch}</command>
5720+
<example>git worktree add ../fix/issue-123 -b fix/issue-123 --no-track origin/main</example>
5721+
<note>--no-track prevents git from setting upstream to base_branch (which would make git push target main!)</note>
57205722
</option_a_new_branch>
57215723
<option_b_existing_branch>
57225724
<condition>Remote branch EXISTS</condition>

src/sources/worktree-add.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,9 @@ Uncommitted changes: `git status --short`
193193
<description>Create the worktree</description>
194194
<option_a_new_branch>
195195
<condition>Remote branch does NOT exist</condition>
196-
<command>git worktree add ${parent_path}/${branch_name} -b ${branch_name} ${base_branch}</command>
197-
<example>git worktree add ../fix/issue-123-main-content-area-visually-clipped -b fix/issue-123-main-content-area-visually-clipped main</example>
196+
<command>git worktree add ${parent_path}/${branch_name} -b ${branch_name} --no-track ${base_branch}</command>
197+
<example>git worktree add ../fix/issue-123 -b fix/issue-123 --no-track origin/main</example>
198+
<note>--no-track prevents git from setting upstream to base_branch (which would make git push target main!)</note>
198199
</option_a_new_branch>
199200
<option_b_existing_branch>
200201
<condition>Remote branch EXISTS</condition>

0 commit comments

Comments
 (0)