code: def git_checkout(repo_dir, ref, branch=None):
      
      command = ['git', 'checkout', '--force']
      if branch:
          command.extend(['-B', '{}'.format(branch)])
      command.append(ref)
      return execute_git_command(command, repo_dir=repo_dir)
docs: Do a git checkout of `ref` in `repo_dir`.
  
      If branch is specified it should be the name of the new branch.