Is there an easy way to clone all flagged repositories from GitHub?

I'm looking for backups of all my tagged repositories, and I'm looking for an easy way to do this.

+6
source share
3 answers

That should do it. note that you will need jq

 curl https://api.github.com/users/<user>/starred | jq -r '.[].html_url' | xargs -l git clone 

If you don't want to use jq , you can replace this ugly awk string

 awk '/^ {4}"html_url"/&&$0=$4' FS='"' | 
+6
source

Yes, here is a simple one-liner (change foo to your username):

 USER=foo; curl "https://api.github.com/users/$USER/starred?per_page=1000" | grep -o ' git@ [^"]*' | xargs -L1 git clone 

Add the -P option to xargs to increase speed by setting the number of parallel processes (for example, -P4 = 4 processes).

To raise the limits of GitHub, you can authenticate by specifying your API key.

+3
source

If you have no problems with ruby ​​and you can set some gems, you can do it.

gem install octokit git parallel

Then it should do it.

 ruby -e "require 'octokit'; require 'git'; require 'parallel'; Parallel.each(Octokit.starred('__username__'), :in_processes=>4){|s| Git.clone(s[:html_url], s[:name])}" 

For readability:

 require 'octokit' require 'git' require 'parallel' Parallel.each(Octokit.starred('__username__'), :in_processes=>4){|s| Git.clone(s[:html_url], s[:name])} 

However, this seems unnecessary.

+2
source

All Articles