Skip to content

Instantly share code, notes, and snippets.

@bashkirtsevich
Last active September 3, 2020 19:49
Show Gist options
  • Save bashkirtsevich/3095062dc79aec0de6beff6def78cd13 to your computer and use it in GitHub Desktop.
Save bashkirtsevich/3095062dc79aec0de6beff6def78cd13 to your computer and use it in GitHub Desktop.
Dump github user
username=$1
repos=$(curl -s https://api.github.com/users/$username/repos?per_page=1000 | jq -r '.[] | .name + "|" + .clone_url')
for repo in $(echo $repos | tr " " "\n")
do
name=$(echo $repo | cut -d"|" -f1)
clone_url=$(echo $repo | cut -d"|" -f2)
git clone --mirror $clone_url ./$username/$name.git && tar -czvf ./$username/$name.tgz -C ./$username/$name.git .
rm -rf ./$username/$name.git
done;
#gists=$(curl -s https://api.github.com/users/$username/gists?page=1&per_page=1000 | jq -r '.[] | .url')
#for repo in $(echo $gists | tr " " "\n")
#do
# git clone --mirror $repo ./$username/$repo.git && tar -czvf ./$username/$repo.tgz -C ./$username/$repo.git .
# rm -rf ./$username/$name.git
#done;
orgs=$(curl -s https://api.github.com/users/$username/orgs?per_page=1000 | jq -r '.[] | .login')
for org in $(echo $orgs | tr " " "\n")
do
repos=$(curl -s https://api.github.com/users/$org/repos?per_page=1000 | jq -r '.[] | .name + "|" + .clone_url')
for repo in $(echo $repos | tr " " "\n")
do
name=$(echo $repo | cut -d"|" -f1)
clone_url=$(echo $repo | cut -d"|" -f2)
git clone --mirror $clone_url ./$org/$name.git && tar -czvf ./$org/$name.tar.gz -C ./$org/$name.git .
rm -rf ./$org/$name.git
done;
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment