Skip to content

stevenmiller888/gity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

101 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gity

NPM version build status license

A nice Git wrapper for Node.

npm install gity

Features

  • Simple, chainable API
  • Small and only one dependency
  • Supports all of the most common git commands
  • By default, provides nicely parsed output from commands like status and log

Examples

var Git = require('gity'); var git = Git() .add('*.js') .commit('-m "added js files"') .run();
var Git = require('gity'); var git = Git() .add('*.js') .commit('-m "added js files"') .status() .run(function(err, res){ // ... { untracked: [], modified: [], created: [], deleted: [] }; });
var Git = require('gity'); var git = Git({ pretty: false }) // passes stdout into res .add('*.js') .commit('-m "added js files"') .status() .run(function(err, res){ // ... });
var Git = require('gity'); var git = Git({ base: '../repo' }) // sets the base folder to '../repo' .init() .run(function(err, res){ // ... });

API

Git(options)

Create a new instance of Gity.

The available options are:

  • base: set the base folder to run the command from, default process.cwd().
  • pretty: give pretty output instead of stdout, default true.

.add()

git.add('-A'); git.add('*.js'); git.add('--All'); git.add('index.js');

.bisect()

git.bisect('start'); git.bisect('bad'); git.bisect('good');

.branch()

git.branch(); // (e.g. 'master') git.branch('-D feature');

.checkout()

git.checkout('feature'); git.checkout('-b demo');

.clone()

git.clone('git://git.kernel.org/pub/scm/.../linux.git my-linux');

.commit()

git.commit('--short'); git.commit('-m "testing"');

.diff()

git.diff('topic master'); git.diff('Readme.md package.json'); git.diff('git diff --name-status');

.fetch()

git.fetch(); git.fetch('origin');

.grep()

git.grep("'time_t' -- '*.[ch]'");

.init()

git.init(); git.init('-q');

.log()

git.log(); git.log('git log --no-merges'); git.log('git log --since="2 weeks ago" -- gitk');

.merge()

git.merge('origin/next');

.mv()

git.mv('oldname newname');

.pull()

git.pull(); git.pull('origin master');

.push()

git.push() git.push('origin master'); git.push('-f origin master');

.rebase()

git.rebase('master'); git.rebase('--onto master next topic');

.reset()

git.reset(); git.reset('--soft HEAD^'); git.reset('--hard HEAD~3');

.rm()

git.rm('oldname');

.show()

git.show('--pretty="format:" --name-only bd61ad98');

.status()

git.status(); git.status('--porcelain');

.tag()

git.tag('-d X');

.run()

git.run(); git.run(function(err, res){ if (err) throw err; console.log(res); });

License

MIT

About

Git wrapper for Node

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors