Created
November 6, 2012 16:25
-
-
Save bradwilson/4025806 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[string]$server = "origin", | |
[string]$branch = "master" | |
) | |
$gitStatus = (Get-GitStatus) | |
if ($gitStatus -eq $null) { | |
write-error "Not in a Git repository." | |
} elseif ($gitStatus.HasUntracked -or $gitStatus.HasWorking -or $gitStatus.HasIndex) { | |
write-error "Can't switch to $branch when you have uncommited changes." | |
} else { | |
$oldBranch = $gitStatus.Branch | |
if ($branch -ne $oldBranch) { git checkout $branch } | |
git pull --rebase $server | |
git remote prune $server | |
if ($branch -ne $oldBranch) { git checkout $oldBranch } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment