Jake Worth

Clone All of an Organization's Git Repos

June 11, 20191 min read

Today, using parts of this Gist I found a command to clone all the repos in a Github organization. Here it is, tested on Ruby 2.3:

$ curl -u <your-username> -s |\
https://api.github.com/orgs/<target-org>/repos?per_page=200 | \
ruby -rubygems -e 'require "json"; JSON.load(STDIN.read).each | \
{ |repo| %x[git clone \"#{repo["ssh_url"]}\" ]}'

Change ssh_url to html_url depending on your privileges and SSH configuration.

This command allowed me to perform some organization-wide searches on an organization with dozens of repos.


Did you enjoy this post? Follow me on Twitter for more.


Jake Worth

I'm Jake Worth, a web developer. Home About Now Newsletter