MCPcopy Create free account
hub / github.com/cli/cli / CheckoutNewBranch

Method CheckoutNewBranch

git/client.go:691–703  ·  view source on GitHub ↗
(ctx context.Context, remoteName, branch string)

Source from the content-addressed store, hash-verified

689}
690
691func (c *Client) CheckoutNewBranch(ctx context.Context, remoteName, branch string) error {
692 track := fmt.Sprintf("%s/%s", remoteName, branch)
693 args := []string{"checkout", "-b", branch, "--track", track}
694 cmd, err := c.Command(ctx, args...)
695 if err != nil {
696 return err
697 }
698 _, err = cmd.Output()
699 if err != nil {
700 return err
701 }
702 return nil
703}
704
705func (c *Client) HasLocalBranch(ctx context.Context, branch string) bool {
706 _, err := c.revParse(ctx, "--verify", "refs/heads/"+branch)

Calls 2

CommandMethod · 0.95
OutputMethod · 0.65