Skip to content

Instantly share code, notes, and snippets.

@jeffhollan
Last active January 6, 2022 05:30
Embed
What would you like to do?
PowerShell script to pull all local branches
function PullAllBranches() {
$branches = git branch
foreach($branch in $branches){
$fixedBranch = $branch.Substring(2, $branch.Length - 2)
$trackedExpression = "branch." + $fixedBranch + ".merge"
$trackedBranch = git config --get $trackedExpression
# Write-Host($trackedBranch)
if(![string]::IsNullOrEmpty($trackedBranch))
{
Write-Host('Pulling branch: ' + $fixedBranch)
git checkout "$fixedBranch" | Out-Null
git pull
}
else {
Write-Host('Branch "' + $fixedBranch + '" has no tracked remote')
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment