I have a company GitHub account and I want to back up all of the repositories within, accounting for anything new that might get created for purposes of automation. I was hoping something like this:
git clone git@github.com:company/*.git
or similar would work, but it doesn't seem to like the wildcard there.
Is there a way in Git to clone and then pull everything assuming one has the appropriate permissions?
You can use open-source tool to clone bunch of github repositories: https://github.com/artiomn/git_cloner
Example:
git_cloner --type github --owner octocat --login user --password user https://my_bitbucket
Use JSON API from
api.github.com
. You can see the code example in the github documentation: https://developer.github.com/v3/Or there:
https://github.com/artiomn/git_cloner/blob/master/src/git_cloner/github.py
I found a comment in the gist @seancdavis provided to be very helpful, especially because like the original poster, I wanted to sync all the repos for quick access, however the vast majority of which were private.
Replace [[USERNAME]] with your github username and [[ORGANIZATION]] with your Github organization. The output (JSON repo metadata) will be passed to a simple ruby script:
To use it (assuming you have nodejs installed)
This would get a list of all the repo's from
wires
and write info into thetest
directory, using the authorisation details (user/pass) you provide on the CLI.In detail, it
It does not actually clone the repos, but instead write a
.txt
file that you can pass intoxargs
to do the cloning, for example:Maybe this is useful for you; it's just a few lines of JS so should be easy to adjust to your needs
So, I will add my answer too. :) (I found it's simple)
Fetch list (I've used "magento" company):
Use
clone_url
insteadssh_url
to use HTTP access.So, let's clone them all! :)
If you are going to fetch private repo's - just add GET parameter
?access_token=YOURTOKEN
A Python3 solution that includes exhaustive pagination via
Link
Header.Pre-requisites:
pip3 install links-from-link-header
Then, you can use
xargs
or parallel and:cat repolist | parallel -I% hub clone %