/node-git-cli

Simple CLI like git interface for Node.

Primary LanguageCoffeeScriptMIT LicenseMIT

node-git-cli Build Status Coverage Status

A simple git interface for NodeJS. It is not intended to replace projects such as nodegit but rather to provide a light weight solution close to the git command line for simple use cases.

Installation

Just run

$ npm install git-cli

Usage

The usage is pretty straightforward, here is a sample code.

Repository = require('git-cli').Repository
fs = require 'fs'

Repository.clone 'https://github.com/tuvistavie/node-git-cli', 'git-cli', (err, repo) ->
  repo.log (err, logs) ->
    console.log logs[0].subject
    repo.showRemote 'origin', (err, remote) ->
      console.log remote.fetchUrl

      fs.writeFileSync "#{repo.workingDir()}/newFile", 'foobar'
      repo.status (err, status) ->
        console.log status[0].path
        console.log status[0].tracked

        repo.add (err) ->
          repo.status (err, status) ->
            console.log status[0].path
            console.log status[0].tracked

            repo.commit 'added newFile', (err) ->
              repo.log (err, logs) ->
                console.log logs[0].subject

              repo.push (err) ->
                console.log 'pushed to remote'

Checkout out the tests for more examples.