Added switch-branch.ps1

This commit is contained in:
Markus Fleschutz
2021-02-13 10:26:14 +01:00
parent 0d969091d0
commit 89c6ff871b
6 changed files with 57 additions and 15 deletions

27
Scripts/switch-branch.ps1 Executable file
View File

@ -0,0 +1,27 @@
#!/bin/powershell
<#
.SYNTAX ./switch-branch.ps1 [<branch>]
.DESCRIPTION switches to the given Git branch
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param($Branch = "")
try {
& git --version
} catch {
write-error "Can't execute 'git' - make sure Git is installed and available"
exit 1
}
try {
if ($Branch -eq "") {
$Branch = read-host "Enter branch name to switch to"
}
& git switch --recurse-submodules $Branch
exit 0
} catch {
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}