From 4a981ae4fa23e39b42fbb6a5d8697843f4c0ffbc Mon Sep 17 00:00:00 2001 From: Ezra Buehler Date: Sat, 29 May 2021 12:07:25 +0200 Subject: [PATCH] Git plugin: create branch if it does not exist Note that if a local branch with the same name already exist, it will be reset to the current HEAD. --- AU/Plugins/Git.ps1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/AU/Plugins/Git.ps1 b/AU/Plugins/Git.ps1 index eef64b3..5bacd18 100644 --- a/AU/Plugins/Git.ps1 +++ b/AU/Plugins/Git.ps1 @@ -51,8 +51,11 @@ if ($User -and $Password) { Add-Content "$env:USERPROFILE\.git-credentials" "https://${Password}:x-oauth-basic@$machine`n" } + +Write-Host "Checking out/resetting $Branch branch" +git checkout -B $Branch + Write-Host "Executing git pull" -git checkout -q $Branch git pull -q origin $Branch $gitAddArgs = @() @@ -92,7 +95,7 @@ else { } Write-Host "Pushing changes" -git push -q +git push origin $Branch if ($commitStrategy -eq 'atomictag') { write-host 'Atomic Tag Push' git push -q --tags