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

Method CheckoutNewBranch

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

Source from the content-addressed store, hash-verified

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