Skip to content

Instantly share code, notes, and snippets.

@smartlime
Last active March 20, 2016 14:08
Show Gist options
  • Select an option

  • Save smartlime/9556b57832cf760511df to your computer and use it in GitHub Desktop.

Select an option

Save smartlime/9556b57832cf760511df to your computer and use it in GitHub Desktop.
Clone/iupdate several git repos at once
#!/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