1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-15 00:15:32 +02:00

specify upstream when pushing a branch for the first time

This commit is contained in:
Jesse Duffield
2019-11-11 23:22:09 +11:00
parent 6843741d9e
commit 12b84307ac
10 changed files with 46 additions and 21 deletions

View File

@ -398,13 +398,18 @@ func (c *GitCommand) Pull(ask func(string) string) error {
}
// Push pushes to a branch
func (c *GitCommand) Push(branchName string, force bool, ask func(string) string) error {
func (c *GitCommand) Push(branchName string, force bool, upstream string, ask func(string) string) error {
forceFlag := ""
if force {
forceFlag = "--force-with-lease "
forceFlag = "--force-with-lease"
}
cmd := fmt.Sprintf("git push %s-u origin %s", forceFlag, branchName)
setUpstreamArg := ""
if upstream != "" {
setUpstreamArg = "--set-upstream " + upstream
}
cmd := fmt.Sprintf("git push %s %s", forceFlag, setUpstreamArg)
return c.OSCommand.DetectUnamePass(cmd, ask)
}