Skip to content

Instantly share code, notes, and snippets.

@computercam
Created May 14, 2020 00:59
Show Gist options
  • Save computercam/39b763df01762292aa446b84309c6097 to your computer and use it in GitHub Desktop.
Save computercam/39b763df01762292aa446b84309c6097 to your computer and use it in GitHub Desktop.
#!/bin/sh
tmp="`mktemp`"
url="https://api.github.com/users/ferrybig/repos?per_page=100"
while [ ! -z "$url" ]; do
echo "Fetching $url..." >&2
curl --dump-header "$tmp" "$url"
url="`< "$tmp" grep Link | grep -oE "[a-zA-Z0-9:/?=.&_]*>; rel=.next" | cut -d'>' -f1`"
done | grep clone_url | cut -d'"' -f4 | while read url;
do
project="`basename "$url"`"
echo "Mirroring $project"
if [ -d "$project" ];
then
cd "$project"
git fetch --prune
cd ..
else
git clone --mirror "$url" "$project"
fi
done
rm "$tmp"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment