Make nodepool git repo caching more robust

Previously, nodepool's prep scripts would not abort when
encountering git cloning errors. Now we retry once on failure and
then abort if it fails a second time. Also the script now makes sure
the clone actually results in a functional copy of each repository
by attempting to list branches and reset to HEAD.

Change-Id: I84565e4e90b34c6a9b8c86754efdde137cda08b2