【问题标题】:How to cache github repos so 2nd git clone will use the cache instead of github repo如何缓存 github 存储库,以便第二个 git clone 将使用缓存而不是 github 存储库
【发布时间】:2014-12-07 16:05:07
【问题描述】:

情景:

1) 我们在中国,所以访问 github 很慢,有时甚至不可能,而且如你所知,我们不能离开 github。

2)我们在开发iOS项目时使用Cocoapods,它使用了很多github repos,所以在安装pods的时候会触发很多git clone git@github.com/reactivecocoa/ReactiveCocoa这样的命令。

那么我们有什么办法可以改进这个过程吗?对我来说最好的解决方案似乎是对这些 github repos 进行本地缓存,当触发 git clone git@github.com/reactivecocoa/ReactiveCocoa 它实际上是在触发 git clone http://192.168.1.199/repos/reactivecocoa/ReactiveCocoa,并且服务器可以判断某个 pod 是否存在,如果存在则返回缓存,否则发出 github 请求并缓存结果。

但找不到可行的策略来实现这一目标,有什么建议吗?

【问题讨论】:

    标签: git caching github


    【解决方案1】:
    git config --global url."git@github.com:reactivecocoa/ReactiveCocoa".insteadOf "http://192.168.1.199/repos/reactivecocoa/ReactiveCocoa"
    

    【讨论】:

    • 它有效!一些提示:192.168.1.199 中的克隆 repos 应该附加--bare,可能需要git update-server-info
    • git config --global url."http://192.168.1.199/repos/reactivecocoa/ReactiveCocoa".insteadOf "git@github.com:reactivecocoa/ReactiveCocoa"
    • 为了更简单,我编写了一个脚本来执行此操作github.com/lzyy/github-proxy
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-14
    • 2020-02-27
    • 2020-06-30
    • 2016-04-24
    • 2015-12-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多