Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

isomorphic-git

Package Overview
Dependencies
Maintainers
1
Versions
408
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

isomorphic-git

A pure JavaScript implementation of git for node and browsers!

  • 0.6.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
346K
decreased by-27.65%
Maintainers
1
Weekly downloads
 
Created

What is isomorphic-git?

isomorphic-git is a pure JavaScript implementation of Git that works in both Node.js and browser environments. It provides a wide range of Git functionalities, allowing developers to perform Git operations without relying on native Git installations.

What are isomorphic-git's main functionalities?

Clone a Repository

This feature allows you to clone a Git repository. The code sample demonstrates how to clone the isomorphic-git repository into a local directory named '/tutorial'.

const git = require('isomorphic-git');
const fs = require('fs');

(async () => {
  await git.clone({
    fs,
    dir: '/tutorial',
    url: 'https://github.com/isomorphic-git/isomorphic-git',
    singleBranch: true,
    depth: 1
  });
  console.log('Cloned the repository!');
})();

Commit Changes

This feature allows you to commit changes to a repository. The code sample demonstrates how to commit changes in the '/tutorial' directory with a commit message 'Initial commit'.

const git = require('isomorphic-git');
const fs = require('fs');

(async () => {
  await git.commit({
    fs,
    dir: '/tutorial',
    author: {
      name: 'Your Name',
      email: 'you@example.com'
    },
    message: 'Initial commit'
  });
  console.log('Committed changes!');
})();

Push to Remote

This feature allows you to push changes to a remote repository. The code sample demonstrates how to push changes from the '/tutorial' directory to the 'main' branch of the remote repository 'origin'.

const git = require('isomorphic-git');
const fs = require('fs');

(async () => {
  await git.push({
    fs,
    dir: '/tutorial',
    remote: 'origin',
    ref: 'main',
    token: 'your-github-token'
  });
  console.log('Pushed to remote!');
})();

Fetch from Remote

This feature allows you to fetch changes from a remote repository. The code sample demonstrates how to fetch changes from the 'origin' remote repository into the '/tutorial' directory.

const git = require('isomorphic-git');
const fs = require('fs');

(async () => {
  await git.fetch({
    fs,
    dir: '/tutorial',
    remote: 'origin'
  });
  console.log('Fetched from remote!');
})();

List Files in a Commit

This feature allows you to list files in a specific commit. The code sample demonstrates how to read the commit object for the 'HEAD' commit and log the tree of files.

const git = require('isomorphic-git');
const fs = require('fs');

(async () => {
  const commit = await git.readCommit({
    fs,
    dir: '/tutorial',
    oid: 'HEAD'
  });
  console.log(commit.commit.tree);
})();

Other packages similar to isomorphic-git

Keywords

FAQs

Package last updated on 10 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc