Use repo.head.target instead of repo.head.get_object().hex