Skip to content

Installation

Terminal window
npm install @keydown-app/ts-git
Terminal window
pnpm add @keydown-app/ts-git
Terminal window
yarn add @keydown-app/ts-git

The package also exports an optional embedded terminal command surface:

Terminal window
npm install @keydown-app/ts-git

Then import the CLI components:

import { CommandParser } from '@keydown-app/ts-git/cli';

For diff functionality, you’ll need a line diff algorithm:

Terminal window
npm install @keydown-app/ts-git-diff-myers

Usage:

import { myersLineDiff } from '@keydown-app/ts-git-diff-myers';
import { GitClient, MemoryFSAdapter } from '@keydown-app/ts-git';
const git = new GitClient({
fs: new MemoryFSAdapter(),
dir: '/my-repo',
lineDiffAlgorithm: myersLineDiff,
});

TS-Git is written in TypeScript and includes type definitions. No additional @types package is needed.

{
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "bundler",
"target": "ES2020"
}
}