# graceful-git

> Executes git commands gracefully. Retries them on errors

Latest version **5.0.0** (published 2026-03-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install graceful-git
pnpm add graceful-git
yarn add graceful-git
bun add graceful-git
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2026-03-11 |
| First published | 2017-04-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=22.13 |
| Dependencies | 2 |
| Unpacked size | 3.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 104 |
| Author | Zoltan Kochan |
| Maintainers | zkochan |
| Keywords | git, retry, retries, exec |

## Links

- npm: https://www.npmjs.com/package/graceful-git
- Repository: https://github.com/zkochan/packages/tree/main/graceful-git
- Homepage: https://github.com/zkochan/packages/tree/main/graceful-git#readme
- npm.io page: https://npm.io/package/graceful-git

## Dependencies (2)

- [retry](https://npm.io/package/retry.md) ^0.13.1
- [safe-execa](https://npm.io/package/safe-execa.md) ^0.3.0

## Recent versions

- 5.0.0 (latest) — 2026-03-11
- 4.0.0 — 2024-07-04
- 3.1.2 — 2021-09-16
- 3.1.1 — 2021-09-15
- 3.1.0 — 2021-09-15
- 3.0.2 — 2020-12-21
- 3.0.1 — 2019-12-19
- 3.0.0 — 2019-11-26
- 2.0.0 — 2018-08-26
- 1.0.3 — 2018-04-09
- 1.0.2 — 2018-03-15
- 1.0.1 — 2017-11-27
- 1.0.0 — 2017-04-12

## README

# graceful-git

> Executes Git commands gracefully. Retries on errors

Git is called by absolute path to avoid binary planting attacks on Windows.

<!--@shields('npm')-->
[![npm version](https://img.shields.io/npm/v/graceful-git.svg)](https://www.npmjs.com/package/graceful-git)
<!--/@-->

## Installation

```sh
<npm|yarn|pnpm> add graceful-git
```

## Usage

<!--@example('./example.js')-->
```js
'use strict'
const gracefulGit = require('graceful-git')

gracefulGit(['status', 'README.md'])
  .then(result => console.log(result.stdout))
  .catch(err => console.error(err))
  //> On branch master
  //  Your branch is based on 'origin/master', but the upstream is gone.
  //    (use "git branch --unset-upstream" to fixup)
  //  nothing to commit, working directory clean
```
<!--/@-->

## API

### `git(args, [opts]) => Promise`

**Arguments:**

- `args` - _string\[]_ - arguments passed to the Git CLI
- `opts.cwd` - _Path_ - the directory in which the Git command should be executed
- `...opts` - _object_ - optional. Parameters used by [retry](https://www.npmjs.com/package/retry) when git operation fails.

### `git.noRetry(args, [opts]) => Promise`

Same as `git()` but without retries.

## License

[MIT](./LICENSE) © [Zoltan Kochan](https://www.kochan.io)

---
_Source: https://npm.io/package/graceful-git · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
