Optimise the git.switch() function