Check if dir is git repo before getting branch name