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

Method UpdateBranch

pkg/cmd/repo/sync/git.go:29–36  ·  view source on GitHub ↗

UpdateBranch moves branch to ref. It uses `git branch --force` rather than `git update-ref` because update-ref will happily move a branch that is checked out in another worktree, leaving that worktree's index and working tree stale.

(branch, ref string)

Source from the content-addressed store, hash-verified

27// `git update-ref` because update-ref will happily move a branch that is checked out in
28// another worktree, leaving that worktree's index and working tree stale.
29func (g *gitExecuter) UpdateBranch(branch, ref string) error {
30 cmd, err := g.client.Command(context.Background(), "branch", "--force", "--", branch, ref)
31 if err != nil {
32 return err
33 }
34 _, err = cmd.Output()
35 return err
36}
37
38func (g *gitExecuter) Worktrees() ([]git.Worktree, error) {
39 return g.client.Worktrees(context.Background())

Calls 2

CommandMethod · 0.80
OutputMethod · 0.65