---
title: "@vltpkg/git: Reference — vlt docs"
description: "Documentation for the vlt client and the vlt registry."
url: "https://docs.vlt.io/client/api-reference/git/reference"
image: "https://docs.vlt.io/og/client/api-reference/git/reference"
lang: "en"
---

# Reference

## Type Aliases

### FindOpts

```ts
type FindOpts = object;
```

Defined in: find.ts:4

#### Type declaration

| Name    | Type     |
| ------- | -------- |
| `cwd`?  | `string` |
| `root`? | `string` |

---

### GitOptions

```ts
type GitOptions = PickManifestOptions & SpawnOptions & object;
```

Defined in: index.ts:18

This extends all options that can be passed to spawn() or pickManifest.

#### Type declaration

| Name                      | Type                                                                         | Description                                                                                                                                              |
| ------------------------- | ---------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `cwd`?                    | `string`                                                                     | the current working directory to perform git operations in                                                                                               |
| `fetch-retries`?          | `WrapOptions`\[`"retries"`]                                                  | Only relevant if `retry` is unset. Value for retry.retries, default 2                                                                                    |
| `fetch-retry-factor`?     | `WrapOptions`\[`"factor"`]                                                   | Only relevant if `retry` is unset. Value for retry.factor, default 10                                                                                    |
| `fetch-retry-maxtimeout`? | `WrapOptions`\[`"maxTimeout"`]                                               | Only relevant if `retry` is unset. Value for retry.maxTimeout, default 60_000                                                                            |
| `fetch-retry-mintimeout`? | `WrapOptions`\[`"minTimeout"`]                                               | Only relevant if `retry` is unset. Value for retry.minTimeout, default 1_000                                                                             |
| `git`?                    | `string` \| `false`                                                          | the path to git binary, or 'false' to prevent all git operations                                                                                         |
| `git-shallow`?            | `boolean`                                                                    | Set to a boolean to force cloning with/without `--depth=1`. If left undefined, then shallow cloning will only be performed on hosts known to support it. |
| `noGitRevCache`?          | `boolean`                                                                    | Look the refs up afresh, and throw if that fails (the cached lookup resolves `undefined`). The result is still cached.                                   |
| `spec`?                   | [`Spec`](https://docs.vlt.io/client/api-reference/spec/module_index.md#spec) | Parsed git specifier to be cloned, if we have one                                                                                                        |

---

### GitUser

```ts
type GitUser = object;
```

Defined in: user.ts:3

#### Type declaration

| Name     | Type     |
| -------- | -------- |
| `email`? | `string` |
| `name`?  | `string` |

## Variables

### shallowHosts

```ts
const shallowHosts: Set<string>;
```

Defined in: clone.ts:27

Only these whitelisted hosts get shallow cloning. Many hosts (including GHE) don't always support it. A failed shallow fetch takes a LOT longer than a full fetch in most cases, so we skip it entirely. Set opts.gitShallow = true/false to force this behavior one way or the other.

If other hosts are added to this set, then they will be shallowly cloned as well.

## Functions

### clone()

```ts
function clone(
   repo, 
   ref, 
   target?, 
opts?): Promise<string>
```

Defined in: clone.ts:35

#### Parameters

| Parameter | Type                                                                                 | Default value |
| --------- | ------------------------------------------------------------------------------------ | ------------- |
| `repo`    | `string`                                                                             | `undefined`   |
| `ref`     | `string`                                                                             | `'HEAD'`      |
| `target`? | `string`                                                                             | `undefined`   |
| `opts`?   | [`GitOptions`](https://docs.vlt.io/client/api-reference/git/reference.md#gitoptions) | `{}`          |

#### Returns

`Promise`<`string`>

---

### find()

```ts
function find(__namedParameters): Promise<undefined | string>
```

Defined in: find.ts:8

#### Parameters

| Parameter           | Type                                                                             |
| ------------------- | -------------------------------------------------------------------------------- |
| `__namedParameters` | [`FindOpts`](https://docs.vlt.io/client/api-reference/git/reference.md#findopts) |

#### Returns

`Promise`<`undefined` | `string`>

---

### getUser()

```ts
function getUser(opts): Promise<undefined | GitUser>
```

Defined in: user.ts:8

#### Parameters

| Parameter | Type |
| --------- | ---- |
| `opts`    | {}   |

#### Returns

`Promise`<`undefined` | [`GitUser`](https://docs.vlt.io/client/api-reference/git/reference.md#gituser)>

---

### is()

```ts
function is(__namedParameters): Promise<boolean>
```

Defined in: is.ts:3

#### Parameters

| Parameter                | Type                 |
| ------------------------ | -------------------- |
| `__namedParameters`      | { `cwd`: `string`; } |
| `__namedParameters.cwd`? | `string`             |

#### Returns

`Promise`<`boolean`>

---

### isClean()

```ts
function isClean(opts): Promise<boolean>
```

Defined in: is-clean.ts:4

#### Parameters

| Parameter | Type |
| --------- | ---- |
| `opts`    | {}   |

#### Returns

`Promise`<`boolean`>

---

### resolve()

```ts
function resolve(
   repo, 
   ref, 
opts): Promise<undefined | RevDocEntry>
```

Defined in: resolve.ts:13

Given a repo and either a ref or a git specifier Spec object, resolve the appropriate ref that we should clone, ideally witout actually cloning the repository.

#### Parameters

| Parameter | Type                                                                                 | Default value |
| --------- | ------------------------------------------------------------------------------------ | ------------- |
| `repo`    | `string`                                                                             | `undefined`   |
| `ref`     | `string`                                                                             | `'HEAD'`      |
| `opts`    | [`GitOptions`](https://docs.vlt.io/client/api-reference/git/reference.md#gitoptions) | `{}`          |

#### Returns

`Promise`<`undefined` | [`RevDocEntry`](https://docs.vlt.io/client/api-reference/types/reference.md#revdocentry)>

---

### resolveRef()

```ts
function resolveRef(
   revDoc, 
   ref, 
   opts): undefined | RevDocEntry
```

Defined in: resolve.ts:29

Given a repo's RevDoc object and either a ref or a git specifier Spec object, resolve the appropriate ref that we should clone, witout actually cloning the repository.

#### Parameters

| Parameter | Type                                                                                 | Default value |
| --------- | ------------------------------------------------------------------------------------ | ------------- |
| `revDoc`  | [`RevDoc`](https://docs.vlt.io/client/api-reference/types/reference.md#revdoc)       | `undefined`   |
| `ref`     | `string`                                                                             | `'HEAD'`      |
| `opts`    | [`GitOptions`](https://docs.vlt.io/client/api-reference/git/reference.md#gitoptions) | `{}`          |

#### Returns

`undefined` | [`RevDocEntry`](https://docs.vlt.io/client/api-reference/types/reference.md#revdocentry)

---

### revs()

```ts
function revs(repo, opts): Promise<undefined | RevDoc>
```

Defined in: revs.ts:32

#### Parameters

| Parameter | Type                                                                                 |
| --------- | ------------------------------------------------------------------------------------ |
| `repo`    | `string`                                                                             |
| `opts`    | [`GitOptions`](https://docs.vlt.io/client/api-reference/git/reference.md#gitoptions) |

#### Returns

`Promise`<`undefined` | [`RevDoc`](https://docs.vlt.io/client/api-reference/types/reference.md#revdoc)>

---

### spawn()

```ts
function spawn(gitArgs, opts): Promise<Result>
```

Defined in: spawn.ts:47

#### Parameters

| Parameter | Type                                                                                 |
| --------- | ------------------------------------------------------------------------------------ |
| `gitArgs` | `string`\[]                                                                          |
| `opts`    | [`GitOptions`](https://docs.vlt.io/client/api-reference/git/reference.md#gitoptions) |

#### Returns

`Promise`<`Result`>
