The main gitshed functionality.

Pulls together code from previous commits.

The main() wrapper, BUILD files etc. will follow shortly.
Alternatively, checking that the target path doesn't exist in the exception raising part above would be good