Skip to content

Instantly share code, notes, and snippets.

@ChrisPritchard
Last active July 24, 2020 19:40
Show Gist options
  • Save ChrisPritchard/929172610aae3f47e2ac1aaa804ccac0 to your computer and use it in GitHub Desktop.
Save ChrisPritchard/929172610aae3f47e2ac1aaa804ccac0 to your computer and use it in GitHub Desktop.
A simple script that will clone all public *and* private repos the user owns (no forks!) and zip up the results.
#!/bin/bash
# Author: Chris Pritchard (github.com/ChrisPritchard)
# requires jq, 7z and git be installed
# run as ./cloner.sh [personal access token] [UserName]
REPOS=$(curl -s -H "Authorization: token $1" "https://api.github.com/user/repos?&affiliation=owner&per_page=200" | jq -r '.[] | select(.fork==false) | .full_name')
rm -rf ./temp-cloner
mkdir temp-cloner
for REPO in $REPOS; do
git clone -q "https://github.com/$REPO" temp-cloner/$REPO
done
7z a github.zip "./temp-cloner/$2/*"
rm -rf ./temp-cloner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment