Skip to content

Instantly share code, notes, and snippets.

@jeffhollan
Last active January 6, 2022 05:30
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffhollan/2c6afc3d53b815bd7825cd3013a258a7 to your computer and use it in GitHub Desktop.
Save jeffhollan/2c6afc3d53b815bd7825cd3013a258a7 to your computer and use it in GitHub Desktop.
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