Cloning All Your GitHub Repositories or Updating Them in One Command

October 29, 2018

I had a new laptop couple weeks ago at work, and I had to set it up with everything I need including the projects I have been working on from GitHub, I remembered how I usually git clone every project I start working on, it involves going to GitHub to the project page, copy the clone URL then go to my terminal, change directory to my projects directory then execute git clone

But what if I don’t need to do that, what if I just cloned all the repositories at once and update them all with one command, that could save alot of time when I have a new machine or I came back from a long vacation and I want to update all the machines.

The implementation is pretty trivial, I should connect to GitHub API and get the list of repositories for me or the organization I want to clone, iterate over every repo and clone or update it, and because GitHub doesn’t return all repositories in one page I have to repeat that process until I get an empty page.

The following snippet does that, it needs some dependencies like tty-prompt and colorize both can be stripped down, but I line to have colored text and menus for that script.