Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ## Checkout all branches from remote as tracking branches. Based on https://stackoverflow.com/questions/379081/track-all-remote-git-branches-as-local-branches/6300386#6300386
- UPSTREAM=$1
- MYREPO=$2
- MASTERBRANCHNAME="master"
- usage() {
- echo "Usage:"
- echo "$0 <upstream-remote> <target-remote>"
- echo ""
- echo "Example which ensures remote named 'maxandersen' have all the same branches and tags as 'origin'"
- echo "$0 upstream origin"
- exit 1
- }
- if [ -z "$UPSTREAM" ]
- then
- echo Missing upstream remote name.
- usage
- fi
- if [ -z "$MYREPO" ]
- then
- echo Missing target remote name.
- usage
- fi
- git fetch $UPSTREAM
- for brname in `git branch -r | grep "$UPSTREAM" | grep -v $MASTERBRANCHNAME | grep -v HEAD | sed -e 's/.*\///g'`; do git branch --track $brname $UPSTREAM/$brname ; done
- git push --all $MYREPO
- git push --tags $MYREPO
Add Comment
Please, Sign In to add comment