MCPcopy
hub / github.com/cli/cli / CheckoutNewBranch

Method CheckoutNewBranch

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

Source from the content-addressed store, hash-verified

629}
630
631func (c *Client) CheckoutNewBranch(ctx context.Context, remoteName, branch string) error {
632 track := fmt.Sprintf("%s/%s", remoteName, branch)
633 args := []string{"checkout", "-b", branch, "--track", track}
634 cmd, err := c.Command(ctx, args...)
635 if err != nil {
636 return err
637 }
638 _, err = cmd.Output()
639 if err != nil {
640 return err
641 }
642 return nil
643}
644
645func (c *Client) HasLocalBranch(ctx context.Context, branch string) bool {
646 _, err := c.revParse(ctx, "--verify", "refs/heads/"+branch)

Callers 3

checkoutBranchFunction · 0.80
deleteLocalBranchMethod · 0.80

Calls 2

CommandMethod · 0.95
OutputMethod · 0.65

Tested by 1