Skip to content

Commit 5470eee

Browse files
dev: updated git worktree script to work with existing branches
1 parent b1197ef commit 5470eee

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

gwt.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,8 @@ echo "Fetching from origin..."
3636
git fetch origin "$branch_name"
3737

3838
echo "Creating worktree at ../worktrees/$issue_num..."
39-
git worktree add --track -b "$branch_name" "../worktrees/$issue_num" "origin/$branch_name"
39+
if git show-ref --verify --quiet "refs/heads/$branch_name"; then
40+
git worktree add "../worktrees/$issue_num" "$branch_name"
41+
else
42+
git worktree add --track -b "$branch_name" "../worktrees/$issue_num" "origin/$branch_name"
43+
fi

0 commit comments

Comments
 (0)