mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-12 06:02:56 +02:00
Added switch-branch.ps1
This commit is contained in:
27
Scripts/switch-branch.ps1
Executable file
27
Scripts/switch-branch.ps1
Executable 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
|
||||
}
|
Reference in New Issue
Block a user