Skip to content

getReference ​

Lookup a reference to one of the objects in a repository.

Signature ​

ts
class Repository {
  getReference(name: string): Reference;
}

Parameters ​

  • namerequired · string

    Reference name to lookup.

Returns ​

  • Reference

    Git reference.

Errors ​

  • Error

    Throws error if the reference does not exist.

Examples ​

Get HEAD reference from the repository.

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

const repo = await openRepository('.');
const reference = repo.getReference('HEAD');

Released under the MIT License.