如何从 GitHub 一次性克隆所有存储库? [英] How to clone all repos at once from GitHub?

查看:36
本文介绍了如何从 GitHub 一次性克隆所有存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个公司 GitHub 帐户,我想备份其中的所有存储库,以考虑可能为自动化目的而创建的任何新内容.我希望是这样的:

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.

在 Git 中是否有一种方法可以克隆然后提取所有内容,前提是一个人拥有适当的权限?

Is there a way in Git to clone and then pull everything assuming one has the appropriate permissions?

推荐答案

Windows 和所有 UNIX/LINUX 系统上,使用 Git Bash任何其他终端,用您的用户名替换 YOURUSERNAME 并使用:

On Windows and all UNIX/LINUX systems, using Git Bash or any other Terminal, replace YOURUSERNAME by your username and use:

CNTX={users|orgs}; NAME={username|orgname}; PAGE=1
curl "https://api.github.com/$CNTX/$NAME/repos?page=$PAGE&per_page=100" |
  grep -e 'git_url*' |
  cut -d " -f 4 |
  xargs -L1 git clone

  • 设置 CNTX=usersNAME=yourusername,以下载您的所有存储库.
  • 设置 CNTX=orgsNAME=yourorgname,以下载您组织的所有存储库.
    • Set CNTX=users and NAME=yourusername, to download all your repositories.
    • Set CNTX=orgs and NAME=yourorgname, to download all repositories of your organization.
    • 最大页面大小为 100,因此您必须使用正确的页码多次调用它以获取所有存储库(将 PAGE 设置为您想要下载的所需页码).

      The maximum page-size is 100, so you have to call this several times with the right page number to get all your repositories (set PAGE to the desired page number you want to download).

      这是一个执行上述操作的 shell 脚本:https://gist.github.com/erdincay/4f1d2e092c50e78ae1ffa39d13fa404e

      Here is a shell script that does the above: https://gist.github.com/erdincay/4f1d2e092c50e78ae1ffa39d13fa404e

      这篇关于如何从 GitHub 一次性克隆所有存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆