【问题标题】:Is it possible to specify a timeout for `git clone` operation? [duplicate]是否可以为“git clone”操作指定超时? [复制]
【发布时间】:2021-01-17 21:08:04
【问题描述】:

我在脚本中使用了git clone,如果完成的时间比N 分钟长,我想使操作超时。

原因是某些存储库的大小超过 5GB(即使使用 --depth 1),下载可能需要 30 多分钟,具体取决于负载。我想忽略这些存储库。

由于git 无法在克隆之前检查存储库的大小,所以我能想到的唯一解决方案是为git clone 指定超时。这可能吗?

【问题讨论】:

标签: linux git version-control


【解决方案1】:

我建议一个方法:

  1. git clone--depth 1 或克隆单个分支:git clone [remote url] --branch [branch_name] --single-branch [folder](如果需要)

  2. 获取clone 命令的输出,例如:

    正在克隆到“www-gitlab-com”... .....

    接收对象:1% (123/624541),74.61 MiB | 8.14 MiB/s,完成

  3. 您可以观察命令输出几秒钟,如果您看到“1% ... 1.2 GiB”,您就知道您遇到了大型 repo 问题,您可以取消它

【讨论】:

  • --depth 1--single-branch不一样吗?
  • @Shuzheng git-scm.com/docs/git-clone#Documentation/… --depth :创建一个浅克隆,其历史被截断为指定的提交次数。暗示 --single-branch 除非给出 --no-single-branch 来获取所有分支尖端附近的历史记录
  • 谢谢。当指定--branch 时,您确定需要--single-branch--branch 不是暗示对方吗?
猜你喜欢
  • 2014-07-14
  • 1970-01-01
  • 2020-04-18
  • 1970-01-01
  • 1970-01-01
  • 2020-04-07
  • 1970-01-01
  • 1970-01-01
  • 2015-03-26
相关资源
最近更新 更多