The main gitshed functionality.

Pulls together code from previous commits.

The main() wrapper, BUILD files etc. will follow shortly.
Address code review comments.
Address code review comments.
Merge pull request #5 from benjyw/gitshed

The main gitshed functionality.