all questions I found want to avoid timeouts in git push/pull. In my case I want to force them. My push + pulls are all going over ssh to remote machines that might be unavailable at some point in time. For example, I have a script that pushes to two remote public repos. I don’t want that this script hangs forever when it pushes to the first repo and that machine is unavailable. Instead, after some timeout i want the push to fail and continue with the second repo.
Any options here?
I don’t think you can do an automatic fail-over with built-in features. But since Git just uses SSH underneath, it should work to add a
ConnectTimeoutoption for the machines in question in your.ssh/config. Cf.man ssh_config. Then something likegit push foo || git push barin the shell should do what you want.