Last active
May 7, 2020 07:38
-
-
Save IamMohaiminul/6955c4fac6fecc89eff4c6f0a42fada8 to your computer and use it in GitHub Desktop.
Clone all repositories for user and organisation specified at once from GitHub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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