The main gitshed functionality.

Pulls together code from previous commits.

The main() wrapper, BUILD files etc. will follow shortly.
I feel very strongly that early returns are the right thing to do when a function ends with an if or if-else. Both because it more strongly signifies that the not condition is terminal and for keeping the indentation level down. If you don't want to do that in this project that's OK, I can ignore that pattern in code reviews