From 5cca8900649a544d2e0ef0b7032407521858a3d4 Mon Sep 17 00:00:00 2001 From: Ben Broderick Phillips Date: Fri, 4 Jun 2021 17:37:04 -0400 Subject: [PATCH] Fetch specific branch name only in git-branch-push script --- 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 e99a8edbd59f..fb3875e7c330 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."