Skip to content

Commit

Permalink
fix: checkout with -B (#21)
Browse files Browse the repository at this point in the history
-B option will create the new branch if it does not exist, or reset an existing branch.
  • Loading branch information
saitho committed Jul 18, 2021
1 parent 45e998e commit d695ad4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/helpers/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default class Git {
* @throws {Error} if the checkout failed.
*/
async checkout(branch: string) {
await execa('git', ['checkout', branch], this.execaOpts);
await execa('git', ['checkout', '-B', branch], this.execaOpts);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe("git", () => {
await subject.checkout('develop');
expect(execa).toHaveBeenCalledWith(
'git',
['checkout', 'develop'],
['checkout', '-B', 'develop'],
expect.objectContaining(execaOpts)
);
});
Expand Down

0 comments on commit d695ad4

Please sign in to comment.