Skip to content

Introduction

TS-Git is a pure TypeScript implementation of Git that runs entirely in the browser or Node.js environment. It provides a Git-compatible API with pluggable filesystem adapters, allowing you to work with Git repositories using various storage backends.

  • 🔧 Pluggable Filesystem - Works with in-memory, browser storage, or native filesystems
  • 📦 Zero Dependencies - Lightweight implementation with minimal external dependencies
  • 🧪 Well Tested - Comprehensive test suite with 470+ tests
  • 🌐 Browser Native - Run Git operations directly in the browser
  • 💪 Type Safe - Fully typed with TypeScript
Terminal window
npm install @keydown-app/ts-git
import { GitClient, MemoryFSAdapter } from '@keydown-app/ts-git';
// Create a filesystem adapter (in-memory for this example)
const fs = new MemoryFSAdapter();
// Initialize Git client
const git = new GitClient({ fs, dir: '/my-repo' });
// Initialize a repository
await git.init({ defaultBranch: 'main' });
// Stage and commit files
await git.add('README.md');
await git.commit('Initial commit', {
name: 'John Doe',
email: 'john@example.com',
});
// View commit history
const commits = await git.log();
CommandStatusDescription
init✅ SupportedInitialize a new Git repository
add✅ SupportedStage file(s) for commit
rm✅ SupportedRemove file(s) from index
commit✅ SupportedCreate a new commit
status✅ SupportedShow working tree status
log✅ SupportedShow commit history
branch✅ SupportedList, create, or delete branches
checkout✅ SupportedSwitch branches
reset✅ SupportedUnstage file(s)
diff✅ SupportedShow changes between commits/index/worktree