-
-
Save esironal/e82d062fc800f8fc31e8 to your computer and use it in GitHub Desktop.
Clones as usual but creates local tracking branches for all remote branches.
This file contains hidden or 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 | |
| # Clones as usual but creates local tracking branches for all remote branches. | |
| # To use, copy this file into the same directory your git binaries are (git, git-flow, git-subtree, etc) | |
| clone_output=$((git clone "$@" ) 2>&1) | |
| retval=$? | |
| echo $clone_output | |
| if [[ $retval != 0 ]] ; then | |
| exit 1 | |
| fi | |
| pushd $(echo $clone_output | head -1 | sed 's/Cloning into .\(.*\).\.\.\./\1/') > /dev/null 2>&1 | |
| this_branch=$(git branch | sed 's/^..//') | |
| for i in $(git branch -r | grep -v HEAD); do | |
| branch=$(echo $i | perl -pe 's/^.*?\///') | |
| # this doesn't have to be done for each branch, but that's how I did it. | |
| remote=$(echo $i | sed 's/\/.*//') | |
| if [[ "$this_branch" != "$branch" ]]; then | |
| git branch -t $branch $remote/$branch | |
| fi | |
| done | |
| popd > /dev/null 2>&1 | |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
to use it, just copy it into your git bin directory (for me, that’s "C:\Program Files (x86)\Git\bin\git-cloneall")
then, on the command line:
git cloneall [standard-clone-options]