Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git: retry if http request failed

Tags:

git

http

In our Continuous Integration environment we do very heavy usage of git clone and git update.

Sometimes the network or the central git server is not reliable.

Is there a way to tell git to retry if the http request failed?

Example:

500 Internal Server Error while accessing https://example.com/repos/foo_bar/info/refs?service=git-upload-pack

like image 234
guettli Avatar asked Jan 26 '16 12:01

guettli


2 Answers

Run below command

while ! git push; do sleep 7; done

like image 132
SteveScm Avatar answered Oct 24 '22 20:10

SteveScm


This is a wrapper around git commands, it recognizes when a command fails and retries

git retry [-v] [-c COUNT] [-d DELAY] [-e] — <git_subcommand>

More information on this can be found here.

like image 39
Phil Avatar answered Oct 24 '22 18:10

Phil