Skip to content

branches

Create an iterator which loops over the requested branches.

Signature

ts
class Repository {
  branches(filter?: BranchesFilter | null | undefined): Branches;
}

Parameters

  • filternull | BranchesFilter

    Filter for the branches iterator.

    • typeBranchType

      Branch type to filter.

      - Local : A local branch not on a remote.
      - Remote : A branch for a remote.

Returns

  • Branches

    An iterator which loops over the requested branches.

Examples

ts
import { openRepository } from 'es-git';

const repo = await openRepository('/path/to/repo');

for (const branch of repo.branches()) {
  console.log(branch.type); // "Local"
  console.log(branch.name); // "main"
}

Released under the MIT License.