Skip to content

Instantly share code, notes, and snippets.

@burritoOverflow
Created August 20, 2023 05:24
Show Gist options
  • Save burritoOverflow/478db482ac7d6d0acad67aa9c3e7c78f to your computer and use it in GitHub Desktop.
Save burritoOverflow/478db482ac7d6d0acad67aa9c3e7c78f to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
if ! command -v gh &> /dev/null || ! command -v jq &> /dev/null
then
echo "requires both gh and jq"
exit 1
fi
if [ -z "$1" ]
then
echo "./cloneallrepos.sh githubusername"
exit 2
fi
USER=$1
echo "cloning repos for user: $USER"
REPOS=`gh api users/$USER/repos --paginate --jq '.[].ssh_url' | sort`
OUTDIR=$USER"githubrepos"
mkdir -p $OUTDIR
pushd `pwd`
cd $OUTDIR
while IFS= read -r line; do
echo "cloning $line"
git clone $line
done <<< "$REPOS"
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment