diff --git a/Generate-GitBranches.ps1 b/Generate-GitBranches.ps1 index 66e5d90b..0700df60 100644 --- a/Generate-GitBranches.ps1 +++ b/Generate-GitBranches.ps1 @@ -52,8 +52,11 @@ try { if ($Pull) { git fetch origin if ($LASTEXITCODE) { throw } - git branch -f $branch origin/$branch - if ($LASTEXITCODE) { throw } + $existingRemoteBranch = git rev-parse --verify origin/$branch 2>$null + if ($existingRemoteBranch) { + git branch -f $branch origin/$branch + if ($LASTEXITCODE) { throw } + } } git checkout -f $branch if ($LASTEXITCODE) { throw }