mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-09 18:19:32 +02:00
28 lines
595 B
PowerShell
Executable File
28 lines
595 B
PowerShell
Executable File
#!/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
|
|
}
|