Not active, see this fork
A simple Node.js wrapper for the Git CLI. The API is based on Grit
$ npm install gift
For existing repositories:
git = require 'gift'
repo = git "path/to/repo"
# => #<Repo>
Initialize a new repository:
git = require 'gift'
git.init "path/to/repo", (err, _repo) ->
repo = _repo
# => #<Repo>
Initialize a new bare repository:
git = require 'gift'
git.init "path/to/bare/repo", true, (err, _repo) ->
repo = _repo
# => #<Repo>
Clone a repository:
git = require 'gift'
git.clone "git@host:path/to/remote/repo.git", "path/to/local/clone/repo", (err, _repo) ->
repo = _repo
# => #<Repo>
String
- The path to the repository.
Get a list of commits.
treeish
-String
(optional).limit
-Integer
(optional).skip
-Integer
(optional).callback
-Function
which receives(err, commits)
, wherecommits
is anArray
ofCommit
s.
Get the 10 most recent commits to master.
repo.commits (err, commits) ->
Or to a different tag or branch.
repo.commits "v0.0.3", (err, commits) ->
Limit the maximum number of commits returned.
repo.commits "master", 30, (err, commits) ->
Skip some (for pagination):
repo.commits "master", 30, 30, (err, commits) ->
The Tree
object for the treeish (which defaults to "master").
repo.tree().contents (err, children) ->
for child in children
console.log child.name
Get the difference between the trees.
The callback receives (err, diffs)
.
Get the commit identity for this repository.
The callback receives (err, actor)
, where actor
is an Actor.
Set your account's default identity for commits to this repository.
The callback receives (err)
.
Get the repository's remotes.
Receives (err, remotes)
, where each remote is a Ref.
Get a list of the repository's remote names.
Get the string names of each of the remotes.
Equivalent to git remote add <name> <url>
.
Remove a remote.
git fetch <name>
git push <name>
Uses --porcelain
to parse repository status in a way that is agnostic of system language. The callback receives (err, status)
. See below for a definition of what status
is.
git config
parsed as a simple, one-level object. The callback receives (err, config)
.
Create a new branch with name
, and call the callback when complete
with an error, if one occurred.
Delete the branch name
, and call the callback with an error, if one occurred.
Get a list of Tag
s.
Create a tab with the given name.
Delete the tag with the given name.
callback
receives (err, heads)
.
Create a branch with the given name.
Delete the branch with the given name.
Get a branch.
branch
- The name of the branch to get. Defaults to the currently checked out branch.callback
- Receives(err, head)
.
Commit some changes.
message
-String
options
-all
-Boolean
amend
-Boolean
callback
- Receives(err)
.
git add <files>
git rm <files>
git checkout <treeish>
Sync the current branch with the remote, keeping all local changes intact.
The following steps are carried out: stash
, pull
, push
, stash pop
. If there were no changes to stash, the last stash pop
is not executed.
remote
-String
(defaults toorigin
).branch
-String
(defaults tomaster
).callback
- Receives(err)
.
String
- The commit's SHA.
Commit[]
callback
- Receives(err, tree)
.
Actor
Date
Actor
Date
String
String
Commit
String
Commit
The callback receives (err, message)
(message
is a String).
The callback receives (err, actor)
.
The callback receives (err, date)
.
Object
- The keys are dotted precisely as the console output from git config
. E.g., {'user.name': 'John Doe'}
Boolean
Object
- The keys are files, the values objects indicating whether or not
the file is staged, tracked, etc.
Each file has the following properties:
type
- "A" for added, "M" for modified, "D" for deleted.staged
-Boolean
tracked
-Boolean
String
String
String
- The MD5 hash of the actor's email. Useful for displaying
Gravatar avatars.
String
- SHA1
callback
- Receives(err, children)
.children
- An array ofBlob
s,Tree
s, andSubmodule
s.
callback
- Receives(err, child_blobs)
.children
-[Blob]
callback
- Receives(err, child_trees)
.children
-[Tree]
directory
-String
callback
- Receives(err, thing)
.
String
- SHA1
String
callback
-(err, data)
String
String
String
Get the url the submodule points to.
See LICENSE.