Skip to content

Instantly share code, notes, and snippets.

@tonyg
Created May 25, 2009 21:43
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 tonyg/117767 to your computer and use it in GitHub Desktop.
Save tonyg/117767 to your computer and use it in GitHub Desktop.
Keep a set of clones of your github repos up-to-date.
#!/bin/bash
# Keep a set of clones of your github repos up-to-date. Run this in a
# directory of its own. It will clone (or update) your github repos into
# subdirectories, one per repo. Written on OS X Leopard.
# Depends on /usr/bin/xpath.
# Make sure you set githubuser, below, to the correct value :-)
githubuser=tonyg
for repo in $(curl http://github.com/api/v1/xml/$githubuser | xpath '//repository/name' 2>/dev/null | sed -e 's:><:> <:g')
do
repo=$(echo $repo | sed -e 's:<name>::' -e 's:</name>::')
echo $repo ...
if [ -d $repo ]
then
(cd $repo; git pull)
else
git clone git://github.com/$githubuser/$repo.git
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment