From 63a01161977722616d1789b58f4594e18182189d Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Fri, 4 Jun 2021 16:11:15 -0700 Subject: [PATCH] Fetch specific branch name only in git-branch-push script (#2374) Co-authored-by: Ben Broderick Phillips --- eng/common/scripts/git-branch-push.ps1 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/eng/common/scripts/git-branch-push.ps1 b/eng/common/scripts/git-branch-push.ps1 index e99a8edbd..fb3875e7c 100644 --- a/eng/common/scripts/git-branch-push.ps1 +++ b/eng/common/scripts/git-branch-push.ps1 @@ -37,7 +37,7 @@ param( [boolean] $AmendCommit = $false ) -# This is necessay because of the janky git command output writing to stderr. +# This is necessary because of the git command output writing to stderr. # Without explicitly setting the ErrorActionPreference to continue the script # would fail the first time git wrote command output. $ErrorActionPreference = "Continue" @@ -116,8 +116,9 @@ do $needsRetry = $true Write-Host "Git push failed with LASTEXITCODE=$($LASTEXITCODE) Need to fetch and rebase: attempt number=$($tryNumber)" - Write-Host "git fetch $RemoteName" - git fetch $RemoteName + Write-Host "git fetch $RemoteName $PRBranchName" + # Full fetch will fail when the repo is in a sparse-checkout state, and single branch fetch is faster anyway. + git fetch $RemoteName $PRBranchName if ($LASTEXITCODE -ne 0) { Write-Error "Unable to fetch remote LASTEXITCODE=$($LASTEXITCODE), see command output above."