Refactored so that the correct exceptions are thrown, especially when there is an git repo.