The main gitshed functionality.

Pulls together code from previous commits.

The main() wrapper, BUILD files etc. will follow shortly.
continue for `self._is_managed` would make this safer since there is no more code in the loop