When checking out a remote branch by name, ask the user how

The choices are to create a new local branch that tracks the remote, or a
detached head.
This commit is contained in:
Stefan Haller 2024-03-15 20:56:44 +01:00
parent 0360b82aab
commit e42cbf95ae
4 changed files with 94 additions and 0 deletions

View file

@ -28,6 +28,17 @@ func (self *BranchCommands) New(name string, base string) error {
return self.cmd.New(cmdArgs).Run()
}
// CreateWithUpstream creates a new branch with a given upstream, but without
// checking it out
func (self *BranchCommands) CreateWithUpstream(name string, upstream string) error {
cmdArgs := NewGitCmd("branch").
Arg("--track").
Arg(name, upstream).
ToArgv()
return self.cmd.New(cmdArgs).Run()
}
// CurrentBranchInfo get the current branch information.
func (self *BranchCommands) CurrentBranchInfo() (BranchInfo, error) {
branchName, err := self.cmd.New(