Skip to content

Instantly share code, notes, and snippets.

@AndrewPaglusch
Last active April 25, 2022 14:09
Show Gist options
  • Select an option

  • Save AndrewPaglusch/e631629b38613cccf8baab1d5c5a7088 to your computer and use it in GitHub Desktop.

Select an option

Save AndrewPaglusch/e631629b38613cccf8baab1d5c5a7088 to your computer and use it in GitHub Desktop.
Download All Public GitHub Repos for User
github_username='YourUsernameHere'
github_pat='YourGitHubPATHere'
curl -s -u "${github_username}:${github_pat}" 'https://api.github.com/user/repos?per_page=100' | grep -oP '(?<=clone_url\":[ ]\")[^(\",)]+' | sed "s|https://|https://${github_username}:${github_pat}@|" | while read repo; do
reponame=$(grep -oP '(?<=\/)[^\/]+$' <<< $repo | sed 's/.git//')
if [ -d $reponame ]; then
echo "$reponame exists. Pulling latest changes..."
cd "$reponame"
git reset --hard
git pull --ff-only
cd -
else
echo "Cloning $reponame..."
git clone "$repo" "$reponame"
fi
echo; echo
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment