Skip to content

Instantly share code, notes, and snippets.

@MarcHeiden
Last active August 25, 2022 18:22
Show Gist options
  • Save MarcHeiden/6485a81a3f9247bc167d4fdd7f7fbce1 to your computer and use it in GitHub Desktop.
Save MarcHeiden/6485a81a3f9247bc167d4fdd7f7fbce1 to your computer and use it in GitHub Desktop.
Checkout all remote git branches locally
$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