How to clone all repos at once from GitHub?

2020-01-25 12:41发布

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?

26条回答
别忘想泡老子
2楼-- · 2020-01-25 13:15

If you have list of repositories in a list like this, then this shell script works:

user="https://github.com/user/"

declare -a arr=("repo1", "repo2")

for i in "${arr[@]}"

do

   echo $user"$i"

   git clone $user"$i"

done 
查看更多
家丑人穷心不美
3楼-- · 2020-01-25 13:16

Update from May 19

use this bash command for an organization (private repo included)

curl -u "{username}" "https://api.github.com/orgs/{org}/repos?page=1&per_page=100" | grep -o 'git@[^"]*' | xargs -L1 git clone
查看更多
登录 后发表回答