Last active
January 6, 2022 05:30
-
-
Save jeffhollan/2c6afc3d53b815bd7825cd3013a258a7 to your computer and use it in GitHub Desktop.
PowerShell script to pull all local branches
This file contains hidden or 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
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