Checkout the deploy branch, creating it if it doesn't exist.
768230
def checkout_deploy_branch(deploy_branch, canpush=True):
    
    # Create an empty branch with .nojekyll if it doesn't already exist
    create_deploy_branch(deploy_branch, push=canpush)
    remote_branch = "doctr_remote/{}".format(deploy_branch)
    print("Checking out doctr working branch tracking", remote_branch)
    clear_working_branch()
    # If gh-pages doesn't exist the above create_deploy_branch() will create
    # it we can push, but if we can't, it won't and the --track would fail.
    if run(['git', 'rev-parse', '--verify', remote_branch], exit=False) == 0:
        extra_args = ['--track', remote_branch]
    else:
        extra_args = []
    run(['git', 'checkout', '-b', DOCTR_WORKING_BRANCH] + extra_args)
    print("Done")

    return canpush
125829
def checkout(config, rev):
    """"""
    with open(config, 'r'):
        main.checkout(yaml.load(open(config)), rev)
1099675
def _checkout(self):
        
        cmd = ["atomic", "mount", "--storage", "ostree", self.ref_image_name, self.mount_point]
        # self.mount_point has to be created by us
        self._run_and_log(cmd, self.ostree_path,
                          "Failed to mount selected image as an ostree repo.")
1296062
def finish(self):
        
        self.repo.git.checkout(self.current_branch)
        self.repo.close()
894793
async function createPr(
  branchName,
  title,
  body,
  labels,
  useDefaultBranch,
  statusCheckVerify
) {
  const base = useDefaultBranch ? config.defaultBranch : config.baseBranch;
  // Include the repository owner to handle forkMode and regular mode
  const head = `${config.repository.split('/')[0]}:${branchName}`;
  const options = {
    body: {
      title,
      head,
      base,
      body,
    },
  };
  // istanbul ignore if
  if (config.forkToken) {
    options.token = config.forkToken;
    options.body.maintainer_can_modify = true;
  }
  logger.debug({ title, head, base }, 'Creating PR');
  const pr = (await get.post(
    `repos/${config.parentRepo || config.repository}/pulls`,
    options
  )).body;
  logger.debug({ branch: branchName, pr: pr.number }, 'PR created');
  // istanbul ignore if
  if (config.prList) {
    config.prList.push(pr);
  }
  pr.displayNumber = `Pull Request #${pr.number}`;
  pr.branchName = branchName;
  await addLabels(pr.number, labels);
  if (statusCheckVerify) {
    logger.debug('Setting statusCheckVerify');
    await setBranchStatus(
      branchName,
      `${appSlug}/verify`,
      `${appName} verified pull request`,
      'success',
      urls.homepage
    );
  }
  return pr;
}
1312492
def release(ctx, deploy=False, test=False, version=''):
    
    if test:
        run("python setup.py check")
        run("python setup.py register sdist upload --dry-run")

    if deploy:
        run("python setup.py check")
        if version:
            run("git checkout master")
            run("git tag -a v{ver} -m 'v{ver}'".format(ver=version))
            run("git push")
            run("git push origin --tags")
            run("python setup.py sdist bdist_wheel")
            run("twine upload --skip-existing dist/*")
    else:
        print("- Have you updated the version?")
        print("- Have you updated CHANGELOG.md, README.md, and AUTHORS.md?")
        print("- Have you fixed any last minute bugs?")
        print("- Have you merged changes for release into the master branch?")
        print("If you answered yes to all of the above questions,")
        print("then run `inv release --deploy -vX.YY.ZZ` to:")
        print("- Checkout master")
        print("- Tag the git release with provided vX.YY.ZZ version")
        print("- Push the master branch and tags to repo")
358485
public function createBranch($name, $checkout = false) {
		$this->begin();
		// git branch $name
		$this->run('git branch', $name);
		if($checkout) {
			$this->checkout($name);
		}
		return $this->end();
	}
789822
public function deploy()
    {
        $this->logger->notice('Deploying ' . $this->name . ' (' . $this->releaseIdentifier . ')');
        $this->workflow->run($this);
    }
1164481
function () {
				grunt.config('release.localBranch', 'release_' + new Date().getTime());
				var command = [
					'git fetch --tags ' + grunt.config('release.remoteRepository'),
					'git fetch ' + grunt.config('release.remoteRepository'),
					'git checkout -b ' + grunt.config('release.localBranch') + ' ' +
						grunt.config('release.remoteRepository') + '/' + grunt.config('release.remoteBaseBranch')
				].join(' && ');
				grunt.log.write('Checking out new local branch based on ' + grunt.config('release.remoteBaseBranch') + ': ' + command);
				return command;
			}
1284076
def do_commit(repo, message_template, branch_name, hexsha):
    ""
    repo.git.add(repo.working_tree_dir)

    if not repo.git.diff(staged=True):
        _LOGGER.warning('No modified files in this Autorest run')
        return False

    checkout_and_create_branch(repo, branch_name)
    msg = message_template.format(hexsha=hexsha)
    commit = repo.index.commit(msg)
    _LOGGER.info("Commit done: %s", msg)
    return commit.hexsha
167749
def create(self, repo_slug=None, key=None, label=None):
        
        key = '%s' % key
        repo_slug = repo_slug or self.bitbucket.repo_slug or ''
        url = self.bitbucket.url('SET_DEPLOY_KEY',
                                 username=self.bitbucket.username,
                                 repo_slug=repo_slug)
        return self.bitbucket.dispatch('POST',
                                       url,
                                       auth=self.bitbucket.auth,
                                       key=key,
                                       label=label)
345817
def checkout(self, branch_name):
        
        try:
            find(
                self.repo.branches, lambda b: b.name == branch_name
            ).checkout()
        except OrigCheckoutError as e:
            raise CheckoutError(branch_name, details=e)
308860
def checkout(branch_name, opts = {})
      args = []
      args << '--no-track' if opts[:no_track]
      args << '-b' if opts[:new_branch]
      args << branch_name
      args << opts[:new_branch] if opts[:new_branch]
      branches = branches()
      command(:checkout, args)

      branches << GitBranch.new(branch_name, opts[:new_branch] != nil, self)

      if block_given?
        yield
        command(:checkout, branches.current.name)
        branches.current
      else
        branches[branch_name]
      end
    end
1278275
protected void createBranchIfNeeded(String branch) throws Exception {
        fetch(); // in case the branch is not known locally
        if (localRepo.findRef(branch) == null) {
            git.branchCreate()
               .setName(branch)
               .setUpstreamMode(SetupUpstreamMode.TRACK)
               .setStartPoint("origin/" + branch)
               .call();
        }
    }
431875
protected void gitFetchRemoteAndCreate(final String branchName)
            throws MojoFailureException, CommandLineException {
        if (!gitCheckBranchExists(branchName)) {
            getLog().info(
                    "Local branch '"
                            + branchName
                            + "' doesn't exist. Trying to fetch and check it out from '"
                            + gitFlowConfig.getOrigin() + "'.");
            gitFetchRemote(branchName);
            gitCreateAndCheckout(branchName, gitFlowConfig.getOrigin() + "/"
                    + branchName);
        }
    }
136146
def checkout(target, options = {})
      options[:strategy] ||= :safe
      options.delete(:paths)

      return checkout_head(options) if target == "HEAD"

      if target.kind_of?(Rugged::Branch)
        branch = target
      else
        branch = branches[target]
      end

      if branch
        self.checkout_tree(branch.target, options)

        if branch.remote?
          references.create("HEAD", branch.target_id, force: true)
        else
          references.create("HEAD", branch.canonical_name, force: true)
        end
      else
        commit = Commit.lookup(self, self.rev_parse_oid(target))
        references.create("HEAD", commit.oid, force: true)
        self.checkout_tree(commit, options)
      end
    end
1204116
def deploy():
    

    init_tasks()

    if not has_hook("copy"):
        return report("No copy method has been defined")

    if not env.exists(paths.get_shared_path()):
        return report("You need to run setup before running deploy")

    run_hook("before_deploy")

    release_name = int(time.time()*1000)
    release_path = paths.get_releases_path(release_name)

    env.current_release = release_path

    try:
        run_hook("copy")
    except Exception as e:
        return report("Error occurred on copy. Aborting deploy", err=e)

    if not env.exists(paths.get_source_path(release_name)):
        return report("Source path not found '%s'" %
                      paths.get_source_path(release_name))

    try:
        run_hook("deploy")
    except Exception as e:
        message = "Error occurred on deploy, starting rollback..."

        logger.error(message)
        logger.error(e)

        run_task("rollback")
        return report("Error occurred on deploy")

    # Symlink current folder
    paths.symlink(paths.get_source_path(release_name),
                  paths.get_current_path())

    # Clean older releases
    if "max_releases" in env:
        cleanup_releases(int(env.max_releases))

    run_hook("after_deploy")

    if "public_path" in env:
        paths.symlink(paths.get_source_path(release_name), env.public_path)

    logger.info("Deploy complete")