Skip to content

Commit 45421ed

Browse files
committed
Updated git branch commands
1 parent a175a8f commit 45421ed

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/github/operations/branch.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ async function setupWorkingBranch(context: GitHubContext, octokit: Octokits): Pr
181181

182182
if (useExistingBranch) {
183183
try {
184-
await $`git checkout ${sourceBranch}`;
184+
await $`git checkout -B ${sourceBranch} origin/${sourceBranch}`;
185185

186186
console.log(`✓ Successfully checked out PR branch for PR #${entityNumber}`);
187187

@@ -220,7 +220,7 @@ async function setupWorkingBranch(context: GitHubContext, octokit: Octokits): Pr
220220
return await createNewBranch(baseBranch, branchName, prBaseBranch)
221221
}
222222

223-
await $`git checkout ${baseBranch}`;
223+
await $`git checkout -B ${baseBranch} origin/${baseBranch}`;
224224

225225
return {
226226
baseBranch: baseBranch,
@@ -243,7 +243,7 @@ export async function ensureBranchHistory(branch: string, depth?: number) {
243243
console.log(`Fetching full history of ${branch}...`);
244244

245245
try {
246-
await $`git fetch origin ${depth ? `--depth=${depth}` : ""} ${branch}`;
246+
await $`git fetch origin ${depth ? `--depth=${depth}` : ""} +${branch}:refs/remotes/origin/${branch}`;
247247
console.log(`✓ Successfully fetched ${branch} history`);
248248
} catch (error) {
249249
throw new Error(

0 commit comments

Comments
 (0)