Skip to content

Commit fd98c61

Browse files
committed
Fix SSH trunk branch: use origin/ prefix for remote tracking branches
After git clone from bundle, branches exist as remote tracking branches (origin/*), not as local branches. When creating a new branch from trunk, we need to reference it as 'origin/trunkBranch' to properly resolve the ref. Updated checkout command to try: 1. Checkout branch if it exists locally 2. Create from origin/trunkBranch (remote tracking branch) 3. Fallback to trunkBranch (local branch, shouldn't be needed) This ensures the trunk branch ref is properly resolved after git clone.
1 parent 94d934a commit fd98c61

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/runtime/SSHRuntime.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,9 +688,11 @@ export class SSHRuntime implements Runtime {
688688
initLogger.logStep("Files synced successfully");
689689

690690
// 2. Checkout branch remotely
691-
// If branch exists, check it out; otherwise create it from the specified trunk branch
691+
// If branch exists locally, check it out; otherwise create it from the specified trunk branch
692+
// Note: After git clone from bundle, branches exist as origin/* refs, so we need to check both
693+
// local branch and origin/branch when creating the new branch
692694
initLogger.logStep(`Checking out branch: ${branchName}`);
693-
const checkoutCmd = `(git checkout ${shescape.quote(branchName)} 2>/dev/null || git checkout -b ${shescape.quote(branchName)} ${shescape.quote(trunkBranch)})`;
695+
const checkoutCmd = `(git checkout ${shescape.quote(branchName)} 2>/dev/null || git checkout -b ${shescape.quote(branchName)} origin/${shescape.quote(trunkBranch)} 2>/dev/null || git checkout -b ${shescape.quote(branchName)} ${shescape.quote(trunkBranch)})`;
694696

695697
const checkoutStream = await this.exec(checkoutCmd, {
696698
cwd: workspacePath, // Use the full workspace path for git operations

0 commit comments

Comments
 (0)