【问题标题】:How to automaticly git clone all your private repositories? (on github using the api)如何自动 git 克隆您所有的私有存储库? (在 github 上使用 api)
【发布时间】:2020-12-11 22:49:00
【问题描述】:

作为一个想要自动化一切的人,我想知道如何使用 linux 下的 github public api(v3) 自动将我所有的私有和公共存储库下载到我的磁盘上。使用 /bin/sh。

问候

【问题讨论】:

    标签: git api github download repository


    【解决方案1】:

    这是一个有点老套的解决方案,我有点渴望看到一个干净的解决方案。无论如何,也许有人也需要这个,由于我没有在网上找到解决方案,我会尽快解释。

    您可以执行的原始代码可以在这里找到:https://gist.github.com/Pierrefha/0436e7bf907d5ed794fe489b06bbac14

    首先我们使用 curl 来获取所有公共和私有 repos 的列表。

    curl -u USERNAME:TOKENVALUE \
    -H "Accept: application/vnd.github.v3+json" \
    https://api.github.com/user/repos
    

    然后我们只选择包含 git url 的行。

    grep git_url
    

    现在我们将 .com 之前的所有内容替换为“,最后用一个空字符串替换”

    sed -E sQ.*.com\/\|\",QQg
    

    最后但并非最不重要的是,我们使用剩余的字符串(我们的 repos 的确切名称)并使用 xargs 来克隆 repos。

    xargs -I% git clone git@github.com:%
    

    我们完成了。

    【讨论】:

      猜你喜欢
      • 2022-08-08
      • 1970-01-01
      • 2021-09-04
      • 2022-01-23
      • 2020-09-23
      • 2021-09-16
      • 2021-02-04
      • 2020-09-20
      • 2014-12-12
      相关资源
      最近更新 更多