Jake Worth

Clone All of an Organization's Git Repos

June 11, 20191 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.

Blog of Jake Worth, software engineer in Maine.

© 2022 Jake Worth.