Skip to content

createBranch

Create a new branch pointing at a target commit

A new direct reference will be created pointing to this target commit.

Signature

ts
class Repository {
  createBranch(
    branchName: string,
    target: Commit,
    options?: CreateBranchOptions | null | undefined,
  ): Branch;
}

Parameters

  • branchNamerequired · string

    Name for the new branch.

  • targetrequired · Commit

    Target commit which will be pointed by this branch.

  • optionsnull | CreateBranchOptions

    Options for create branch.

    • forceboolean

      If force is true and a reference already exists with the given name, it'll be replaced.

Returns

  • Branch

    Newly created branch.

Released under the MIT License.