Last Updated: February 25, 2016
·
2.287K
· stuartpb

Retry git push as long as the server is down

With GitHub currently in the midst of a furious DDOS attack, I'm stuck waiting for the attack to end or be mitigated so I can push my code.

If you have a shell command, like git push, that's currently failing, and you want it to continuously execute until it's successful, you can call it as the inverse condition of a while loop. If you don't want to be part of an incidental DDOS yourself, you can add a sleep 7 call in the body of the loop so it will wait seven seconds before trying again (the number of seconds to sleep can be increased or decreased commensurate to your level of patience).

So, in summary, to continuously try to push your changes until they are successfully uploaded, fire up a new terminal and run:

while ! git push; do sleep 7; done

1 Response
Add your response

You can also add something at the end to alert when it pushes successfully: echo -ne "\a" will work if your PC speaker / bell is enabled.

over 1 year ago ·