Create a new branch like `git branch <branch_name> <start_point>`.
493551
def git_branch(repo_dir, branch_name, start_point='HEAD',
               force=True, verbose=True, checkout=False):
    """"""
    command = ['git', 'branch']
    if verbose:
        command.append('--verbose')
    if force:
        command.append('--force')
    command.extend([branch_name, start_point])
    branch_output = execute_git_command(command, repo_dir=repo_dir)
    if checkout:
        return git_checkout(repo_dir, branch_name)
    else:
        return branch_output
936334
private void branch(int stackAdjust, Location location, byte opcode) {
        if (!(location instanceof InstructionList.LabelInstruction)) {
            throw new IllegalArgumentException("Branch location is not a label instruction");
        }
        mInstructions.new BranchInstruction(stackAdjust, opcode,
                                            (InstructionList.LabelInstruction)location);
    }
110889
def create_branch(branch, path = Dir.pwd)
      #ap method(__method__).parameters.map { |arg| arg[1] }
      g = MiniGit.new(path)
      error "not yet any commit performed -- You shall do one" unless commits?(path)
      g.branch branch.to_s
    end
55261
def plan_branches(self, plan_key, expand=None, favourite=False, clover_enabled=False, max_results=25):
        """"""
        resource = 'plan/{}/branch'.format(plan_key)
        return self.base_list_call(resource, expand, favourite, clover_enabled, max_results,
                                   elements_key='branches', element_key='branch')
723215
def create(self, repo_name, scm='git', private=True, **kwargs):
        
        url = self.bitbucket.url('CREATE_REPO')
        return self.bitbucket.dispatch('POST', url, auth=self.bitbucket.auth, name=repo_name, scm=scm, is_private=private, **kwargs)
954227
def git_checkout(branch_name, create=False):
    # type: (str, bool) -> None
    
    log.info("Checking out <33>{}".format(branch_name))
    shell.run('git checkout {} {}'.format('-b' if create else '', branch_name))
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;
}
909356
def init(ctx, client, directory, name, force, use_external_storage):
    """"""
    if not client.use_external_storage:
        use_external_storage = False

    ctx.obj = client = attr.evolve(
        client,
        path=directory,
        use_external_storage=use_external_storage,
    )

    msg = 'Initialized empty project in {path}'
    branch_name = None

    stack = contextlib.ExitStack()

    if force and client.repo:
        msg = 'Initialized project in {path} (branch {branch_name})'
        merge_args = ['--no-ff', '-s', 'recursive', '-X', 'ours']

        try:
            commit = client.find_previous_commit(
                str(client.renku_metadata_path),
            )
            branch_name = 'renku/init/' + str(commit)
        except KeyError:
            from git import NULL_TREE
            commit = NULL_TREE
            branch_name = 'renku/init/root'
            merge_args.append('--allow-unrelated-histories')

        ctx.obj = client = stack.enter_context(
            client.worktree(
                branch_name=branch_name,
                commit=commit,
                merge_args=merge_args,
            )
        )

    try:
        with client.lock:
            path = client.init_repository(name=name, force=force)
    except FileExistsError:
        raise click.UsageError(
            'Renku repository is not empty. '
            'Please use --force flag to use the directory as Renku '
            'repository.'
        )

    stack.enter_context(client.commit())

    with stack:
        # Install Git hooks.
        from .githooks import install
        ctx.invoke(install, force=force)

        # Create all necessary template files.
        from .runner import template
        ctx.invoke(template, force=force)

    click.echo(msg.format(path=path, branch_name=branch_name))
21591
def create(self):
        
        self.add_handlers({'^Q': self.quit})
        self.add(npyscreen.TitleText,
                 name='Select which tools to add from each branch selected:',
                 editable=False)
        self.add(npyscreen.Textfield,
                 value='NOTE tools you have already installed will be ignored',
                 color='STANDOUT',
                 editable=False)

        i = 6
        for branch in self.parentApp.repo_value['versions']:
            self.tools_tc[branch] = {}
            self.add(npyscreen.TitleText,
                     name='Branch: ' + branch,
                     editable=False,
                     rely=i,
                     relx=5,
                     max_width=25)
            tools = self.repo_tools(branch)
            i += 1
            for tool in tools:
                value = True
                if tool.startswith('/dev'):
                    value = False
                # tool in base directory
                if tool == '' or tool.startswith(':'):
                    tool = '/' + tool
                self.tools_tc[branch][tool] = self.add(npyscreen.CheckBox,
                                                       name=tool,
                                                       value=value,
                                                       relx=10)
                i += 1
            i += 2
680239
public void checkout(String branch) throws Exception {
        if (!branch.equals(getBranch())) {
            createBranchIfNeeded(branch);
            git.checkout().setName(branch).setStartPoint("origin/" + branch)
                .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK).call();
            // for some reason jgit needs this when branch is switched
            git.checkout().setName(branch).call();
        }
    }
754913
def check_out_branch
      git.check_out branch_to_merge_into
    rescue Git::NoBranchOfType
      cli.say "No #{branch_type} branch available. Creating one now."
      git.check_out DatedBranchCreator.perform(branch_type).branch_name
    end
339168
def call_git_branch():
    """"""
    try:
        with open(devnull, "w") as fnull:
            arguments = [GIT_COMMAND, 'rev-parse', '--abbrev-ref', 'HEAD']
            return check_output(arguments, cwd=CURRENT_DIRECTORY,
                                stderr=fnull).decode("ascii").strip()
    except (OSError, CalledProcessError):
        return None
800795
def branches(type = :master, dir = Dir.pwd, _options = {})
      FalkorLib::Git.config("gitflow.branch.#{type}", dir)
      #confs[type.to_sym]
    end
343937
async function createPr(
  branchName,
  title,
  description,
  labels,
  useDefaultBranch = true
) {
  // labels is not supported in Bitbucket: https://bitbucket.org/site/master/issues/11976/ability-to-add-labels-to-pull-requests-bb

  const base = useDefaultBranch ? config.defaultBranch : config.baseBranch;

  logger.debug({ repository: config.repository, title, base }, 'Creating PR');

  const body = {
    title,
    description,
    source: {
      branch: {
        name: branchName,
      },
    },
    destination: {
      branch: {
        name: base,
      },
    },
    close_source_branch: true,
  };

  const prInfo = (await api.post(
    `/2.0/repositories/${config.repository}/pullrequests`,
    { body }
  )).body;
  const pr = { number: prInfo.id, displayNumber: `Pull Request #${prInfo.id}` };
  // istanbul ignore if
  if (config.prList) {
    config.prList.push(pr);
  }
  return pr;
}
1087815
def git_clone(target_dir, repo_location, branch_or_tag=None, verbose=True):
    
    target_dir = pipes.quote(target_dir)
    command = ['git', 'clone']
    if verbose:
        command.append('--verbose')
    if os.path.isdir(repo_location):
        command.append('--no-hardlinks')
    command.extend([pipes.quote(repo_location), target_dir])
    if branch_or_tag:
        command.extend(['--branch', branch_or_tag])
    return execute_git_command(command)
759611
public Ref checkoutBranch(Git git, String branch) {
        try {
            return git.checkout()
                .setName(branch)
                .call();
        } catch (GitAPIException e) {
            throw new IllegalStateException(e);
        }
    }
675360
def start(config, bugnumber=""):
    """"""
    repo = config.repo

    if bugnumber:
        summary, bugnumber, url = get_summary(config, bugnumber)
    else:
        url = None
        summary = None

    if summary:
        summary = input('Summary ["{}"]: '.format(summary)).strip() or summary
    else:
        summary = input("Summary: ").strip()

    branch_name = ""
    if bugnumber:
        if is_github({"bugnumber": bugnumber, "url": url}):
            branch_name = "{}-".format(bugnumber)
        else:
            branch_name = "{}-".format(bugnumber)

    def clean_branch_name(string):
        string = re.sub(r"\s+", " ", string)
        string = string.replace(" ", "-")
        string = string.replace("->", "-").replace("=>", "-")
        for each in "@%^&:'\"/(),[]{}!.?`$<>#*;=":
            string = string.replace(each, "")
        string = re.sub("-+", "-", string)
        string = string.strip("-")
        return string.lower().strip()

    branch_name += clean_branch_name(summary)

    if not branch_name:
        error_out("Must provide a branch name")

    # Check that the branch doesn't already exist
    found = list(find(repo, branch_name, exact=True))
    if found:
        error_out("There is already a branch called {!r}".format(found[0].name))

    new_branch = repo.create_head(branch_name)
    new_branch.checkout()
    if config.verbose:
        click.echo("Checkout out new branch: {}".format(branch_name))

    save(config.configfile, summary, branch_name, bugnumber=bugnumber, url=url)