I have some git commands scripted in python and occasionally git fetch can hang for hours if there is no connectivity. Is there a way to time it out and report a failure instead?
No you can't, you need to timeout the command using a wrapper.
Can you specify a timeout to git fetch?