Split git repo discovery into separate script

This step runs on the bootstrap machine where a git repo is present.
Everything else runs on the generator machine, where we can build
the required binaries.

(cherry picked from commit 7d0e8824f5f01ab7b1e17ec7fe23a456a4b14f9f)