Handle git checkout when pwd is not under git
Always switch to a file's folder before checkout