Skip to content

defaultBranch ​

Get the remote’s default branch.

The fetch operation from the remote is also performed.

Signature ​

ts
class Remote {
  defaultBranch(signal?: AbortSignal | null | undefined): Promise<string>;
}

Parameters ​

  • signalnull | AbortSignal

    Abort signal.

Returns ​

  • Promise<string>

    Default branch name.

Examples ​

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

const repo = await openRepository('/path/to/repo');
const remote = repo.getRemote('origin');

const branch = await remote.defaultBranch();
console.log(branch); // "refs/heads/main"

Released under the MIT License.