A simple Node.js wrapper for the Git CLI. The API is based on Grit
$ npm install gift
git = require 'gift'
repo = git "path/to/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 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>
.
git fetch <name>
The callback receives (err, status)
.
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>
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)
.
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.