Skip to content

Commit

Permalink
fix: set upstream branch for existing remote branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinzent03 committed Aug 28, 2022
1 parent 91f8446 commit c454b9d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/simpleGit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,20 @@ export class SimpleGit extends GitManager {
}

async updateUpstreamBranch(remoteBranch: string) {
await this.git.push(["--set-upstream", ...remoteBranch.split("/")], (err) => this.onError(err));
try {
// git 1.8+
await this.git.branch(['--set-upstream-to', remoteBranch]);
} catch (e) {
console.error(e);
try {
// git 1.7 - 1.8
await this.git.branch(['--set-upstream', remoteBranch]);
} catch (e) {
console.error(e);
// fallback
await this.git.push(["--set-upstream", ...remoteBranch.split("/")], (err) => this.onError(err));
}
}

}

Expand Down

0 comments on commit c454b9d

Please sign in to comment.