Socket
Socket
Sign inDemoInstall

js-git

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-git

Git Implemented in JavaScript


Version published
Weekly downloads
1.3M
decreased by-1.43%
Maintainers
1
Weekly downloads
 
Created

What is js-git?

The js-git npm package is a JavaScript implementation of Git. It allows you to interact with Git repositories directly from JavaScript, enabling functionalities such as reading and writing commits, branches, and tags, as well as handling Git objects and references.

What are js-git's main functionalities?

Read a Git Commit

This feature allows you to read a Git commit by its hash. The code sample demonstrates how to load a commit object and log its contents.

const jsGit = require('js-git');
const repo = jsGit();
repo.loadAs('commit', 'commit-hash', (err, commit) => {
  if (err) throw err;
  console.log(commit);
});

Write a Git Commit

This feature allows you to write a new Git commit. The code sample demonstrates how to create a commit object and save it to the repository.

const jsGit = require('js-git');
const repo = jsGit();
const commit = {
  tree: 'tree-hash',
  author: { name: 'Author Name', email: 'author@example.com', date: new Date() },
  message: 'Commit message'
};
repo.saveAs('commit', commit, (err, hash) => {
  if (err) throw err;
  console.log('Commit saved with hash:', hash);
});

List References

This feature allows you to list references in a Git repository. The code sample demonstrates how to list all branch references.

const jsGit = require('js-git');
const repo = jsGit();
repo.listRefs('refs/heads', (err, refs) => {
  if (err) throw err;
  console.log(refs);
});

Read a Git Tree

This feature allows you to read a Git tree object by its hash. The code sample demonstrates how to load a tree object and log its contents.

const jsGit = require('js-git');
const repo = jsGit();
repo.loadAs('tree', 'tree-hash', (err, tree) => {
  if (err) throw err;
  console.log(tree);
});

Other packages similar to js-git

Keywords

FAQs

Package last updated on 24 Jan 2017

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