A simple Node.js wrapper for the Git CLI. The API uses promises. This library is used in Codebox.
npm install gittle
var Gittle = require("gittle");
- Load a repository:
var repo = new Gittle("./");
- Clone a repository:
Gittle.clone("https://github.com/FriendCode/gittle.js.git", "./test")
- Initialize an empty repository:
Gittle.init("./test")
Check out Authentication about how to configure https/ssh authentication for cloning.
- Get status:
repo.status()
- Get identity:
repo.identity()
, Returns an Actor object - Set identity:
repo.identify(actor)
, actor is an object like:{name: "", email: ""}
- Pull:
repo.pull(remote, branch)
- Push:
repo.push(remote, branch)
- Fetch:
repo.fetch(remote)
Check out Authentication about how to configure https/ssh authentication.
A commit is representated by a Commit object.
- List all commits:
repo.commits(start, limit, skip)
- Commit changes:
repo.commit(message, options)
- List all tags:
repo.tags()
- Create a new tag:
repo.create_tag(name, options)
- Delete a tag:
repo.delete_tag(name)
A branch is representated by a Head object.
- List all branches:
repo.branches()
- Get a branch from its name:
repo.branche(name)
- Create a branch:
repo.create_branch(name)
- Delete a branch:
repo.delete_branch(name)
- List all remotes:
repo.remotes()
- Add a remote:
repo.remore_add(name, url)
- Delete a remote:
repo.remote_remove(name)
commit.id
: (String) id for this commitcommit.author
: (Actor) author of this commitcommit.commiter
: (Actor) commiter of this commitcommit.message
: (String) message for this commitcommit.authored_date
: (String) date when the commit was authoredcommit.committed_date
: (String) date when the commit was commited- Get the files tree for this commit:
commit.tree()
- Get the parents commits:
commit.parents()
actor.name
: (String) name of this actoractor.email
: (String) email address of this actoractor.hash
: (String) hash of this actor (md5 hash of the email)
Class Head inherit from Ref.
ref.name
: (String) name of this referenceref.commit
: (Commit) commit related to this ref.
A last argument could be use for authentication on Gittle.clone
, repo.push
, repo.pull
, repo.fetch
:
{
// SSH:
'passphrase': "...",
'refuseUnknownHost': true, // Default is false
// HTTPS:
'username': "...",
'password': "..."
}