From e368269995c4c99a8852fd9bd950610fdb45a888 Mon Sep 17 00:00:00 2001 From: d3oxy Date: Thu, 2 Apr 2026 17:34:12 +0530 Subject: [PATCH] fix: use explicit refspec when pushing branches without upstream in worktrees MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When pushing a branch that has no upstream tracking configured (the `pushWithUpstream` path in `pushCurrentBranch`), git is invoked as: git push -u This fails in git worktrees when the branch name contains a slash (e.g. `t3code/my-feature`), with: fatal: cannot be resolved to branch This is a known git limitation — bare branch names with slashes cannot be resolved from a linked worktree's context during push. The branch ref exists (verified via `git rev-parse`), and `git branch --show-current` reports it correctly, but `git push` fails to resolve it. The fix uses an explicit refspec instead: git push -u HEAD:refs/heads/ This is semantically equivalent but bypasses the branch name resolution issue by using HEAD (always valid) as the source ref and the fully qualified target ref path. The `pushWithUpstream` code path is only reached when the branch has no upstream configured — branches that already track a remote use the simpler `git push` without a branch argument, which is unaffected by this issue. --- apps/server/src/git/Layers/GitCore.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/server/src/git/Layers/GitCore.ts b/apps/server/src/git/Layers/GitCore.ts index 0a11abab5b..d3748312f4 100644 --- a/apps/server/src/git/Layers/GitCore.ts +++ b/apps/server/src/git/Layers/GitCore.ts @@ -1341,7 +1341,7 @@ export const makeGitCore = Effect.fn("makeGitCore")(function* (options?: { "push", "-u", publishRemoteName, - branch, + `HEAD:refs/heads/${branch}`, ]); return { status: "pushed" as const,