Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Clone all repositories of a Github user
curl -s https://api.github.com/users/milanboers/repos | grep \"clone_url\" | awk '{print $2}' | sed -e 's/"//g' -e 's/,//g' | xargs -n1 git clone
@Pulecz

This comment has been minimized.

Copy link

Pulecz commented May 1, 2018

change url to https://api.github.com/users/${user}/repos?per_page=200.

?per_page=200 ensures you get at least 200 repos checked, the default limit seems to be about 30 repos.

@themalkolm

This comment has been minimized.

Copy link

themalkolm commented May 6, 2018

Came from google :)

If you install jq tool then it is much easier, no need to fight with json

curl -s "https://api.github.com/users/milanboers/repos?per_page=100" | jq -r ".[].git_url" | xargs -L1 git clone
@IdanBanani

This comment has been minimized.

Copy link

IdanBanani commented Oct 24, 2018

Came from google :)

If you install jq tool then it is much easier, no need to fight with json

curl -s "https://api.github.com/users/milanboers/repos?per_page=100" | jq -r ".[].git_url" | xargs -L1 git clone

It worked, after a lot of messing around (downloading nodejs, then npm, then jq (with chochalate something pkgmgr) and using the xargs.exe of the github for windows /usr/bin folder (xargs.exe has some dependencies with dll files so It might be a good idea to make a copy of this folder and to run the script from there, or maybe just use Linux / cygwin / mingw ?

@IdanBanani

This comment has been minimized.

Copy link

IdanBanani commented Oct 24, 2018

what was the original idea? (the json output file)

@leandrocodes

This comment has been minimized.

Copy link

leandrocodes commented Sep 6, 2019

Have an ssh alternative?

@mazunki

This comment has been minimized.

Copy link

mazunki commented Sep 26, 2019

I made a folder called gits in my home folder, and added this to download_all_gits.sh:

curl -s https://api.github.com/users/$(git config user.name)/repos | jq -r ".[].ssh_url" | xargs -L1 git clone

After chmod +x download_all_gits.sh, I could run ./download_all_gits.sh to download with ssh, @leandrocodes.

It won't overwrite already existing folders, so it is great to use to download all new repositories.

@kwcooper

This comment has been minimized.

Copy link

kwcooper commented Mar 12, 2020

Worked like a charm. Thanks mate!

@2KAbhishek

This comment has been minimized.

Copy link

2KAbhishek commented Mar 15, 2020

If anyone is having trouble pushing to the repos with git_url, this will be useful.

curl -s "https://api.github.com/users/milanboers/repos?per_page=100" | jq -r ".[].html_url" | xargs -L1 git clone
@anaggh

This comment has been minimized.

Copy link

anaggh commented Mar 21, 2020

Thanks! I wanted to clone all repos(including private) with ssh

curl -s -H "Authorization: token YOUR_TOKEN_HERE" "https://api.github.com/user/repos?per_page=100" | jq -r ".[].ssh_url" | xargs -L1 git clone
@Justintime50

This comment has been minimized.

Copy link

Justintime50 commented Apr 27, 2020

After some searching and frustrations of my own not being able to do this easily, I built out a project that allows for public and private repo cloning of both personal and organization repos. Perfect for grabbing everything you'd need:

https://github.com/Justintime50/github-archive

@mazunki

This comment has been minimized.

Copy link

mazunki commented Apr 27, 2020

After some searching and frustrations of my own not being able to do this easily, I built out a project that allows for public and private repo cloning of both personal and organization repos. Perfect for grabbing everything you'd need:

https://github.com/Justintime50/github-archive

Nice! I may fork this over the next day, or do some pull requests adding the option to automatically replace dotfiles. Who wants that, anyway?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.