From 8aacd6915bc72bb3c518ad8a16136c2124af9957 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sun, 5 Aug 2018 18:19:27 +1000 Subject: [PATCH] set upstream to origin branchname on push --- gitcommands.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gitcommands.go b/gitcommands.go index eff864b59..976369317 100644 --- a/gitcommands.go +++ b/gitcommands.go @@ -13,6 +13,11 @@ import ( "github.com/fatih/color" ) +var ( + // ErrNoCheckedOutBranch : When we have no checked out branch + ErrNoCheckedOutBranch = errors.New("No currently checked out branch") +) + // GitFile : A staged/unstaged file // TODO: decide whether to give all of these the Git prefix type GitFile struct { @@ -446,7 +451,11 @@ func gitPull() (string, error) { } func gitPush() (string, error) { - return runDirectCommand("git push -u") + branchName := gitCurrentBranchName() + if branchName == "" { + return "", ErrNoCheckedOutBranch + } + return runDirectCommand("git push -u origin " + branchName) } func gitSquashPreviousTwoCommits(message string) (string, error) {