code: def switch(scm, to_branch, verbose, fake):
      
      scm.fake = fake
      scm.verbose = fake or verbose
  
      scm.repo_check()
  
      if to_branch is None:
          scm.display_available_branches()
          raise click.BadArgumentUsage('Please specify a branch to switch to')
  
      scm.stash_log()
      status_log(scm.checkout_branch, 'Switching to {0}.'.format(
          crayons.yellow(to_branch)), to_branch)
      scm.unstash_log()
docs: Switches from one branch to another, safely stashing and restoring local changes.