Last active
September 19, 2023 23:10
-
-
Save ElfSundae/92a5868f418ec3187dfff90fe6b20387 to your computer and use it in GitHub Desktop.
Git checkout all remote branches
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
#!/bin/bash | |
remote=origin ; for brname in `git branch -r | grep $remote | grep -v /master | grep -v /HEAD | awk '{gsub(/^[^\/]+\//,"",$1); print $1}'`; do git branch --track $brname $remote/$brname || true; done 2>/dev/null |
This is exactly what I wanted. Thank you.
I've added that to my bash aliases file as a function.
function gitCheckoutAllBranches {
remote=origin;
for brname in `git branch -r | grep $remote | grep -v /master | grep -v /HEAD | awk '{gsub(/^[^\/]+\//,"",$1); print $1}'`;
do git branch --track $brname $remote/$brname || true;
done
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Refs: