Git retry revisited

Only retry git commands that hit the network.

Fixes #2885 and the failing build on master.

Reverts #2886.