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.

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.