Skip to main content

Welcome to useGit

useGit is a modern, promise-based Git utility library designed to make Git operations in Node.js straightforward and type-safe. Built with TypeScript, it provides a clean, intuitive API for all your Git automation needs.

Why useGit?

Promise-Based

All operations return promises, making it perfect for async/await workflows and modern JavaScript applications.

Type-Safe

Written in TypeScript with full type definitions, giving you autocomplete and compile-time safety.

Comprehensive API

Covers all essential Git operations: init, clone, add, commit, branch, tag, diff, status, and more.

Flexible Configuration

Create multiple Git instances with different working directories and pass custom flags to any command.

Key Features

Simple and Intuitive

Working with Git should be straightforward. useGit provides a clean API that mirrors Git’s own command structure:
import { git } from 'use-git';

// Initialize a repository
await git.init();

// Add files and commit
await git.add('.');
await git.commit('feat: add new feature');

// Check status
const status = await git.status();

Multiple Repository Support

Create separate Git instances for different repositories:
import { createGit } from 'use-git';

const projectA = createGit({ cwd: './project-a' });
const projectB = createGit({ cwd: './project-b' });

await projectA.add('.');
await projectB.add('.');

Rich API Surface

useGit provides specialized functions for common operations:
  • Status & Inspection: isDirty, isCleanWorkingTree, hasUntrackedFiles
  • Branching: createBranch, currentBranch, listBranches, deleteBranch
  • Tagging: createTag, createAnnotatedTag, getTags, getSemverTags
  • Diffs: diff, diffStaged, diffStats, hasStagedDiff
  • Commits: commit, commitAll, commitAmend, commitSignoff

Get Started

Installation

Install useGit via npm, yarn, or pnpm and set up your project

Quick Start

Follow a step-by-step guide to get up and running in minutes

API Reference

Explore the complete API documentation with examples

GitHub

View the source code and contribute on GitHub

Community & Support

useGit is open source and welcomes contributions. Found a bug or have a feature request? Please open an issue on GitHub.
useGit requires Git to be installed on your system. Check if Git is installed using git.isGitInstalled().

Build docs developers (and LLMs) love