CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-isomorphic-git

A pure JavaScript implementation of git for node and browsers

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

repository-operations.mddocs/

Repository Operations

Core operations for initializing, cloning, and managing Git repositories.

Capabilities

Initialize Repository

Creates a new Git repository in the specified directory.

/**
 * Initialize a new repository
 * @param args.fs - File system client
 * @param args.dir - Working tree directory path
 * @param args.gitdir - Git directory path (defaults to dir/.git)
 * @param args.bare - Initialize as bare repository
 * @param args.defaultBranch - Name of default branch (defaults to 'master')
 * @returns Promise resolving when complete
 */
function init(args: {
  fs: FsClient;
  dir?: string;
  gitdir?: string;
  bare?: boolean;
  defaultBranch?: string;
}): Promise<void>;

Usage Examples:

import git from "isomorphic-git";
import fs from "fs";

// Initialize a new repository
await git.init({
  fs,
  dir: "/path/to/new/repo"
});

// Initialize as bare repository
await git.init({
  fs,
  dir: "/path/to/bare/repo",
  bare: true
});

// Initialize with custom default branch
await git.init({
  fs,
  dir: "/path/to/repo",
  defaultBranch: "main"
});

Clone Repository

Clones a remote repository to the local file system.

/**
 * Clone a repository from a remote URL
 * @param args.fs - File system client
 * @param args.http - HTTP client for network operations
 * @param args.dir - Working tree directory path
 * @param args.gitdir - Git directory path (defaults to dir/.git)
 * @param args.url - URL of remote repository
 * @param args.corsProxy - CORS proxy for browser environments
 * @param args.ref - Branch to checkout (defaults to remote's default branch)
 * @param args.singleBranch - Only fetch a single branch
 * @param args.noCheckout - Skip checkout after clone
 * @param args.noTags - Don't fetch tags
 * @param args.remote - Name for the remote (defaults to 'origin')
 * @param args.depth - Shallow clone depth
 * @param args.since - Only fetch commits after this date
 * @param args.exclude - Branches/tags to exclude
 * @param args.relative - Make depth relative to current shallow depth
 * @param args.headers - Additional HTTP headers
 * @param args.onProgress - Progress callback
 * @param args.onMessage - Message callback
 * @param args.onAuth - Authentication callback
 * @param args.onAuthFailure - Auth failure callback
 * @param args.onAuthSuccess - Auth success callback
 * @param args.cache - Cache object
 * @returns Promise resolving when clone completes
 */
function clone(args: {
  fs: FsClient;
  http: HttpClient;
  dir: string;
  gitdir?: string;
  url: string;
  corsProxy?: string;
  ref?: string;
  singleBranch?: boolean;
  noCheckout?: boolean;
  noTags?: boolean;
  remote?: string;
  depth?: number;
  since?: Date;
  exclude?: string[];
  relative?: boolean;
  headers?: Record<string, string>;
  onProgress?: ProgressCallback;
  onMessage?: MessageCallback;
  onAuth?: AuthCallback;
  onAuthFailure?: AuthFailureCallback;
  onAuthSuccess?: AuthSuccessCallback;
  cache?: object;
}): Promise<void>;

Usage Examples:

import git from "isomorphic-git";
import http from "isomorphic-git/http/node";
import fs from "fs";

// Basic clone
await git.clone({
  fs,
  http,
  dir: "/path/to/repo",
  url: "https://github.com/user/repo.git"
});

// Shallow clone with single branch
await git.clone({
  fs,
  http,
  dir: "/path/to/repo",
  url: "https://github.com/user/repo.git",
  singleBranch: true,
  depth: 1
});

// Clone specific branch with progress tracking
await git.clone({
  fs,
  http,
  dir: "/path/to/repo",
  url: "https://github.com/user/repo.git",
  ref: "develop",
  onProgress: (event) => {
    console.log(`Progress: ${event.phase} ${event.loaded}/${event.total}`);
  }
});

// Browser clone with CORS proxy
await git.clone({
  fs, // LightningFS instance
  http, // isomorphic-git/http/web
  dir: "/repo",
  url: "https://github.com/user/repo.git",
  corsProxy: "https://cors.isomorphic-git.org"
});

Get Version

Returns the version of isomorphic-git.

/**
 * Get the isomorphic-git version
 * @returns Version string
 */
function version(): string;

Usage Example:

import git from "isomorphic-git";

console.log(git.version()); // "1.33.1"

Find Repository Root

Finds the root directory of a Git repository.

/**
 * Find the root of the Git repository
 * @param args.fs - File system client
 * @param args.filepath - Path to start searching from
 * @returns Promise resolving to repository root path
 */
function findRoot(args: {
  fs: FsClient;
  filepath: string;
}): Promise<string>;

Usage Example:

import git from "isomorphic-git";
import fs from "fs";

// Find repo root from any path within the repository
const rootDir = await git.findRoot({
  fs,
  filepath: "/path/to/repo/some/nested/directory"
});
console.log(rootDir); // "/path/to/repo"

docs

advanced-operations.md

branch-management.md

commit-operations.md

configuration.md

error-handling.md

index.md

object-operations.md

reference-management.md

remote-operations.md

repository-operations.md

working-directory.md

tile.json