Skip to content

Instantly share code, notes, and snippets.

@snim2
Forked from abhishekkr/a.github.sh
Created June 17, 2014 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snim2/5915d857910623b09d5e to your computer and use it in GitHub Desktop.
Save snim2/5915d857910623b09d5e to your computer and use it in GitHub Desktop.
#!/bin/bash
# Usage Example: $ clone-github github_id
# would clone all the git repositories managed under github_id at current path
# save it as /etc/profiles/a.github.sh
##
clone-github(){
GITHUB_ID=$1
GITHUB_REPO_URI="https://github.com/"$GITHUB_ID"?tab=repositories"
repos=`curl -skL $GITHUB_REPO_URI | grep 'title="Forks"' | sed "s/.*$GITHUB_ID\///" | sed 's/\/network"\stitle="Forks">//'`
for line in `echo $repos | xargs -L1`;
do
if [ ! -z $line ];
then
repo_git='git://github.com/'$GITHUB_ID'/'$line'.git'
if [ -e $line ]; then
echo 'Fetching master latest pull for: '$repo_git
cd $line ; git pull ; cd -
else
echo "Cloning... "$repo_git
`git clone $repo_git`
fi
fi
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment