A Node.js wrapper for the Git CLI
Gitty is a Node.js wrapper for Git. It's syntax resembles the Git command line syntax, executes common commands, and parses the output into operable objects.
- Node.js 0.8.x (http://nodejs.org)
- Git 1.7.x.x (http://git-scm.com)
- GNU/Linux or Mac OSX
$ npm install gitty
Note: If you encounter an error during installation on Mac OSX, make sure you have the XCode Command Line Tools installed. Gitty depends on pty.js for authenticated operations - which requires GCC compiler.
- Go to the App store and download the latest version of Xcode for free.
- Install Xcode (the app store actually downloads the "installer" for Xcode)
- Start Xcode
- Go to Preferences
- Go to Downloads
- Click on the "install" button after "Command Line Tools"
Run the the unit and integration tests with:
$ npm test
var git = require'gitty';var myRepo = git'/path/to/repo';
Now you can call this instance of
Repository's methods. For example, to
git log for
myRepo, you would do:
myRepo.logif err return console.log'Error:' err;// ...;
For now, use the source, Luke. Pretty much everything you'll need is in
lib/repository.js and it's very readable. Running the test suite will be of
use as well since all public methods are tested and will print to the console.
Since OpenSSH does not read input from
stdin for authentication, but rather a
psuedo-terminal - Gitty uses pty.js (https://github.com/chjj/pty.js/) to
spawn a pseudo-terminal for operations that may require authentication, such as
Credentials are always passed as the last argument before the callback and are
optional. Below is an example of an authenticated
myRepopush'origin' 'master'username: 'username'password: 'password'if err return console.logerr;// ...;
This format is consistent for all authenticated operations. Keep this in mind if you are extending Gitty with an operation that requires authentication, and be sure to read the pty.js documentation.
Gitty was written by Gordon Hall (firstname.lastname@example.org)
Licensed under LGPLv3 license