Last active
March 20, 2016 14:08
-
-
Save smartlime/9556b57832cf760511df to your computer and use it in GitHub Desktop.
Clone/iupdate several git repos at once
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
| #!/usr/bin/env /usr/local/bin/zsh | |
| for repo (`cat .repos`); do | |
| echo -n "Trying repo $repo..." | |
| git ls-remote --exit-code "$repo" HEAD &> /dev/null | |
| if [ $? -eq 0 ]; then | |
| echo "OK" | |
| paths=(${(s:/:)repo}) | |
| rpath="./"$paths[-1] | |
| if [[ -d $rpath ]]; then | |
| echo "PULL" | |
| pushd . | |
| cd $rpath | |
| git pull | |
| popd | |
| else | |
| echo "CLONE" | |
| git clone $repo | |
| fi | |
| else | |
| echo "SKIP" | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment