Add more checks for git repository before executing commands