Move git calls into separate module

This should make things cleaner and easier to test.