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

Method CheckoutNewBranch

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

Source from the content-addressed store, hash-verified

692}
693
694func (c *Client) CheckoutNewBranch(ctx context.Context, remoteName, branch string) error {
695 track := fmt.Sprintf("%s/%s", remoteName, branch)
696 args := []string{"checkout", "-b", branch, "--track", track}
697 cmd, err := c.Command(ctx, args...)
698 if err != nil {
699 return err
700 }
701 _, err = cmd.Output()
702 if err != nil {
703 return err
704 }
705 return nil
706}
707
708func (c *Client) HasLocalBranch(ctx context.Context, branch string) bool {
709 _, 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