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

Method CreateBranch

pkg/cmd/repo/sync/git.go:42–57  ·  view source on GitHub ↗
(branch, ref, upstream string)

Source from the content-addressed store, hash-verified

40}
41
42func (g *gitExecuter) CreateBranch(branch, ref, upstream string) error {
43 ctx := context.Background()
44 cmd, err := g.client.Command(ctx, "branch", branch, ref)
45 if err != nil {
46 return err
47 }
48 if _, err := cmd.Output(); err != nil {
49 return err
50 }
51 cmd, err = g.client.Command(ctx, "branch", "--set-upstream-to", upstream, branch)
52 if err != nil {
53 return err
54 }
55 _, err = cmd.Output()
56 return err
57}
58
59func (g *gitExecuter) CurrentBranch() (string, error) {
60 return g.client.CurrentBranch(context.Background())

Callers

nothing calls this directly

Calls 2

CommandMethod · 0.80
OutputMethod · 0.65

Tested by

no test coverage detected