Last active
August 25, 2022 18:22
-
-
Save MarcHeiden/6485a81a3f9247bc167d4fdd7f7fbce1 to your computer and use it in GitHub Desktop.
Checkout all remote git branches locally
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
$localBranches = [System.Collections.ArrayList]@() | |
$remoteBranches = [System.Collections.ArrayList]@() | |
git branch -r | % { if (!($_.split("/")[1].contains("HEAD")) -and !($_.split("/")[1].contains("main"))) { | |
$localBranches.Add($_.split("/")[1]) | |
$remoteBranches.Add($_) | |
} } | |
$index = 0 | |
foreach ($branch in $localBranches) { | |
git checkout -b $branch $remoteBranches[$index] | |
$index++ | |
Start-Sleep -Seconds 5 | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment