How to Clone All Repositories from a GitHub Account

Use a Bash Script!

If you're like me and use a lot of different devices (and sometimes decide to just wipe your device and start with a new OS), you probably know the pain of cloning all your old code repositories down to your local file system.

If you're using GitHub, you can easily clone all of your code back down in just seconds. First, create a bash script - I do so by opening a new file in gedit, but you can use nano, vim, or something else:


Next, paste in the following information. Note that you can replace the word users in the first line with orgs and type an organization's name instead of a user's name.

curl "$CNTX/$NAME/repos?page=$PAGE&per_page=100" |
  grep -e 'git_url*' |
  cut -d \" -f 4 |
  xargs -L1 git clone

Finally, save the bash script and make it executable.

chmod a+x

Now you can run the script and should see the cloning process begin.