Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to make git over http timeout?

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.

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?

like image 762
Daniel F. Moisset Avatar asked Jun 23 '11 18:06

Daniel F. Moisset


3 Answers

Additional to CAD bloke's answer:

Also

git config --global http.lowSpeedLimit 1000
git config --global http.lowSpeedTime 600

works fine.

The above example means the remote action will block when the speed kept below 1KB/s for 600 seconds(10min), the action will block.

like image 90
Alfred Huang Avatar answered Oct 19 '22 05:10

Alfred Huang


You can try using

http.lowSpeedLimit, http.lowSpeedTime

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.

like image 30
manojlds Avatar answered Oct 19 '22 04:10

manojlds


Add this to .gitconfig ...

[http]
lowSpeedLimit = 1000
lowSpeedTime = 20

lowSpeedLimit is bytes per second

I call it the Codeplex clause.

like image 8
CAD bloke Avatar answered Oct 19 '22 06:10

CAD bloke