Jake Worth

Jake Worth

Clone All of an Organization's Git Repos

Published: June 11, 2019 2 min read

  • git

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.

What are your thoughts on this? Let me know!


Join 100+ engineers who subscribe for advice, commentary, and technical deep-dives into the world of software.