Skip to content

Instantly share code, notes, and snippets.

@huandu
Created October 6, 2012 03:54
Show Gist options
  • Save huandu/3843725 to your computer and use it in GitHub Desktop.
Save huandu/3843725 to your computer and use it in GitHub Desktop.
git checkout all remote branches
#! /bin/bash
REMOTE_NAME=$1
if [ "$REMOTE_NAME" == "" ]; then
cat <<EOF
Usage: $0 remote
remote Remote name, which can be 'origin' in common case.
EOF
exit
fi
git branch -r | sed -e 's/origin\/\(\W*\)$/\1/' -e '/ -> /d' | xargs -I {} git checkout -b {} $REMOTE_NAME/{}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment