Skip to content

Instantly share code, notes, and snippets.

@IamMohaiminul
Last active May 7, 2020 07:38
Show Gist options
  • Select an option

  • Save IamMohaiminul/6955c4fac6fecc89eff4c6f0a42fada8 to your computer and use it in GitHub Desktop.

Select an option

Save IamMohaiminul/6955c4fac6fecc89eff4c6f0a42fada8 to your computer and use it in GitHub Desktop.
Clone all repositories for user and organisation specified at once from GitHub
#!/bin/bash
username=""
token=""
organization=""
suffix=".git"
# clone all repositories for specifed user
for repo in `curl https://api.github.com/user/repos?type=owner\&per_page=100 -u ${username}:${token} | jq .[].ssh_url | sed -e 's/^"//' -e 's/"$//'`
do
echo "Repo found: $repo"
git clone $repo ./$(cut -d':' -f2 <<<"${repo%$suffix}")
done
# clone all repositories for specifed organization
for repo in `curl https://api.github.com/orgs/$organization/repos?type=owner\&per_page=100 -u ${username}:${token} | jq .[].ssh_url | sed -e 's/^"//' -e 's/"$//'`
do
echo "Repo found: $repo"
git clone $repo ./$(cut -d':' -f2 <<<"${repo%$suffix}")
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment