From 261ca3aab45ef01bf2f1e107407b3c4a52cf6fee Mon Sep 17 00:00:00 2001 From: averyjennings Date: Wed, 4 Mar 2026 00:40:37 -0800 Subject: [PATCH] fix: use origin/ ref when branching from default branch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit resolve_default_branch returns a bare branch name (e.g. "main") which points to the local branch. After git fetch, origin/main is up to date but the local main may be stale — causing new worktrees to start from an old commit. The resolved_ref logic in create_worktree compounds this: it tries git rev-parse "main^{commit}" first, which succeeds with the stale local SHA, so the origin/ fallback never runs. Prefix with origin/ so new branches always start from the latest remote. --- lib/commands/create.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/commands/create.sh b/lib/commands/create.sh index f8e89f9..bb991bb 100644 --- a/lib/commands/create.sh +++ b/lib/commands/create.sh @@ -73,12 +73,12 @@ _create_resolve_from_ref() { from_ref=$(get_current_branch) if [ -z "$from_ref" ] || [ "$from_ref" = "HEAD" ]; then log_warn "Currently in detached HEAD state - falling back to default branch" - from_ref=$(resolve_default_branch "$repo_root") + from_ref="origin/$(resolve_default_branch "$repo_root")" else log_info "Creating from current branch: $from_ref" fi else - from_ref=$(resolve_default_branch "$repo_root") + from_ref="origin/$(resolve_default_branch "$repo_root")" fi fi