有没有办法让 git 通过 http 超时? [英] Is there a way to make git over http timeout?

查看:48
本文介绍了有没有办法让 git 通过 http 超时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自动运行 git clone/pull 的脚本(这实际上发生在 jenkins CI 中,但我的问题更笼统).远程 git 服务器基于 HTTPS.带有 git 客户端的机器有一个不稳定的 DSL 互联网连接,因此它有时会重新连接并更改 IP 地址,从而丢失所有现有连接.当 git 客户端运行时连接失败,客户端永远不会成功,但它也不会因超时而失败,所以我的脚本挂断了.

I'm having a script running git clone/pull automatically (this is actually happening inside jenkins CI, but my question is more general). The remote git server is HTTPS based. The machine with the git client has a flaky DSL internet connection, so it sometimes reconnects and changes IP address, losing all its existing connections. When the connection fails while the git client is running, the client never succeeds but it doesn't fail with a timeout either, so my script hangs up.

我想设置客户端,使其在一段时间后超时(以便脚本可以重试、记录失败或采取任何其他操作).但是我在 git-config 手册页中没有找到任何超时选项.我发现了一个相关问题,但它仅适用于 SSH 连接.你知道 http 服务器有没有替代方案?

I'd like to set up the client so it timeouts after some period (so the script can retry, or log a failure, or take any other action). But I didn't find any timeout option in the git-config manpage. I found a related question but it's only for SSH connections. Do you know if there's an alternative for http servers?

推荐答案

可以尝试使用

http.lowSpeedLimit、http.lowSpeedTime

http.lowSpeedLimit, http.lowSpeedTime

如果 HTTP 传输速度较低比 http.lowSpeedLimit 更长比 http.lowSpeedTime 秒,传输中止.可以覆盖通过 GIT_HTTP_LOW_SPEED_LIMIT 和GIT_HTTP_LOW_SPEED_TIME 环境变量.

If the HTTP transfer speed is less than http.lowSpeedLimit for longer than http.lowSpeedTime seconds, the transfer is aborted. Can be overridden by the GIT_HTTP_LOW_SPEED_LIMIT and GIT_HTTP_LOW_SPEED_TIME environment variables.

这篇关于有没有办法让 git 通过 http 超时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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