Repository.discover Async

Repository.discover(startPath, acrossFs, ceilingDirs).then(function(string) {
  // Use string
});

Creates a branch with the passed in name pointing to the commit

Parameters Type  
startPath String The base path where the lookup starts.
acrossFs Number If non-zero, then the lookup will not stop when a filesystem device change is detected while exploring parent directories.
ceilingDirs String A list of absolute symbolic link free paths. the search will stop if any of these paths are hit. This may be set to null
Returns  
String Path of the git repository

Repository.init Async

Repository.init(path, is_bare).then(function(repository) {
  // Use repository
});
Parameters Type  
path String the path to the repository
is_bare Number if true, a Git repository without a working directory is created at the pointed path. If false, provided path will be considered as the working directory into which the .git directory will be created.
Returns  
Repository  

Repository.initExt Async

Repository.initExt(repo_path, opts).then(function(repository) {
  // Use repository
});
Parameters Type  
repo_path String The path to the repository.
opts RepositoryInitOptions Pointer to git_repository_init_options struct.
Returns  
Repository  

Repository.open Async

Repository.open(path).then(function(repository) {
  // Use repository
});
Parameters Type  
path String the path to the repository
Returns  
Repository  

Repository.openBare Async

Repository.openBare(bare_path).then(function(repository) {
  // Use repository
});
Parameters Type  
bare_path String Direct path to the bare repository
Returns  
Repository  

Repository.openExt Async

Repository.openExt(path, flags, ceiling_dirs).then(function(repository) {
  // Use repository
});
Parameters Type  
path String Path to open as git repository. If the flags permit “searching”, then this can be a path to a subdirectory inside the working directory of the repository. May be NULL if flags is GIT_REPOSITORY_OPEN_FROM_ENV.
flags Number A combination of the GIT_REPOSITORY_OPEN flags above.
ceiling_dirs String A GIT_PATH_LIST_SEPARATOR delimited list of path prefixes at which the search for a containing repository should terminate.
Returns  
Repository  

Repository.openFromWorktree Async

Repository.openFromWorktree(wt).then(function(repository) {
  // Use repository
});
Parameters Type  
wt Worktree Working tree to open
Returns  
Repository  

Repository.wrapOdb Async

Repository.wrapOdb(odb).then(function(repository) {
  // Use repository
});
Parameters Type  
odb Odb the object database to wrap
Returns  
Repository  

Repository#checkoutBranch Async

repository.checkoutBranch(branch, opts).then(function() {
  // method complete});

This will set the HEAD to point to the local branch and then attempt to update the index and working tree to match the content of the latest commit on that branch

Parameters Type  
branch String, Reference the branch to checkout
opts Object, CheckoutOptions the options to use for the checkout

Repository#checkoutRef Async

repository.checkoutRef(reference, opts).then(function() {
  // method complete});

This will set the HEAD to point to the reference and then attempt to update the index and working tree to match the content of the latest commit on that reference

Parameters Type  
reference Reference the reference to checkout
opts Object, CheckoutOptions the options to use for the checkout

Repository#cleanup Async

repository.cleanup().then(function() {
  // method complete});

Repository#commondir Sync

var string = repository.commondir();
Returns  
String the path to the common dir

Repository#config Async

repository.config().then(function(config) {
  // Use config
});
Returns  
Config  

Repository#continueRebase Async

repository.continueRebase(signature, beforeNextFn, beforeFinishFn, rebaseOptions).then(function(oid) {
  // Use oid
});

Continues an existing rebase

Parameters Type  
signature Signature Identity of the one performing the rebase
beforeNextFn Function Callback to be called before each step of the rebase. If the callback returns a promise, the rebase will resume when the promise resolves. The rebase object is is passed to the callback.
beforeFinishFn Function Callback called before the invocation of finish(). If the callback returns a promise, finish() will be called when the promise resolves. This callback will be provided a detailed overview of the rebase
rebaseOptions RebaseOptions Options to initialize the rebase object with
Returns  
Oid A commit id for a succesful merge or an index for a rebase with conflicts

Repository#createBlobFromBuffer Async

repository.createBlobFromBuffer(buffer).then(function(oid) {
  // Use oid
});

Create a blob from a buffer

Parameters Type  
buffer Buffer  
Returns  
Oid  

Repository#createBranch Async

repository.createBranch(name, commit, force).then(function(reference) {
  // Use reference
});

Creates a branch with the passed in name pointing to the commit

Parameters Type  
name String Branch name, e.g. “master”
commit Commit, String, Oid The commit the branch will point to
force Boolean Overwrite branch if it exists
Returns  
Reference  

Repository#createCommit Async

repository.createCommit(updateRef, author, committer, message, Tree, parents).then(function(oid) {
  // Use oid
});

Create a commit

Parameters Type  
updateRef String  
author Signature  
committer Signature  
message String  
Tree Oid, String  
parents Array  
Returns  
Oid The oid of the commit

Repository#createCommitBuffer Async

repository.createCommitBuffer(author, committer, message, treeOid, parents).then(function(string) {
  // Use string
});

Create a commit

Parameters Type  
author Signature  
committer Signature  
message String  
treeOid Oid, String  
parents Array  
Returns  
String The content of the commit object as a string

Repository#createCommitOnHead Async

repository.createCommitOnHead(filesToAdd, author, committer, message).then(function(oid) {
  // Use oid
});

Creates a new commit on HEAD from the list of passed in files

Parameters Type  
filesToAdd Array  
author Signature  
committer Signature  
message String  
Returns  
Oid The oid of the new commit

Repository#createCommitWithSignature Async

repository.createCommitWithSignature(updateRef, author, committer, message, Tree, parents, onSignature).then(function(oid) {
  // Use oid
});

Create a commit that is digitally signed

Parameters Type  
updateRef String  
author Signature  
committer Signature  
message String  
Tree Tree, Oid, String  
parents Array  
onSignature Function Callback to be called with string to be signed
Returns  
Oid The oid of the commit

Repository#createLightweightTag Async

repository.createLightweightTag(String, name).then(function(reference) {
  // Use reference
});

Creates a new lightweight tag

Parameters Type  
String String, Oid sha or Oid
name String the name of the tag
Returns  
Reference  

Repository#createRevWalk Sync

var revwalk = repository.createRevWalk();

Instantiate a new revision walker for browsing the Repository”s history. See also Commit.prototype.history()

Returns  
Revwalk  

Repository#createTag Async

repository.createTag(String, name, message).then(function(tag) {
  // Use tag
});

Creates a new annotated tag

Parameters Type  
String String, Oid sha or Oid
name String the name of the tag
message String the description that will be attached to the annotated tag
Returns  
Tag  

Repository#defaultSignature Async

repository.defaultSignature().then(function(signature) {
  // Use signature
});

Gets the default signature for the default user and now timestamp

Returns  
Signature  

Repository#deleteTagByName Async

repository.deleteTagByName(Short).then(function() {
  // method complete});

Deletes a tag from a repository by the tag name.

Parameters Type  
Short String or full tag name

Repository#detachHead Sync

var result = repository.detachHead();
Returns  
Number 0 on success, GIT_EUNBORNBRANCH when HEAD points to a non existing
branch or an error code  

Repository#fetch Async

repository.fetch(remote, fetchOptions).then(function() {
  // method complete});

Fetches from a remote

Parameters Type  
remote String, Remote  
fetchOptions Object, FetchOptions Options for the fetch, includes callbacks for fetching

Repository#fetchAll Async

repository.fetchAll(fetchOptions, callback).then(function() {
  // method complete});

Fetches from all remotes. This is done in series due to deadlocking issues with fetching from many remotes that can happen.

Parameters Type  
fetchOptions Object, FetchOptions Options for the fetch, includes callbacks for fetching
callback Function  

Repository#fetchheadForeach Async

repository.fetchheadForeach(callback).then(function() {
  // method complete});
Parameters Type  
callback FetchheadForeachCb The callback function to be called on each entry

Repository#getBlob Async

repository.getBlob(String).then(function(blob) {
  // Use blob
});

Retrieve the blob represented by the oid.

Parameters Type  
String String, Oid sha or Oid
Returns  
Blob  

Repository#getBranch Async

repository.getBranch(name).then(function(reference) {
  // Use reference
});

Look up a branch. Alias for getReference

Parameters Type  
name String, Reference Ref name, e.g. “master”, “refs/heads/master” or Branch Ref
Returns  
Reference  

Repository#getBranchCommit Async

repository.getBranchCommit(name).then(function(commit) {
  // Use commit
});

Look up a branch’s most recent commit. Alias to getReferenceCommit

Parameters Type  
name String, Reference Ref name, e.g. “master”, “refs/heads/master” or Branch Ref
Returns  
Commit  

Repository#getCommit Async

repository.getCommit(String).then(function(commit) {
  // Use commit
});

Retrieve the commit identified by oid.

Parameters Type  
String String, Oid sha or Oid
Returns  
Commit  

Repository#getCurrentBranch Async

repository.getCurrentBranch().then(function(reference) {
  // Use reference
});

Gets the branch that HEAD currently points to Is an alias to head()

Returns  
Reference  

Repository#getHeadCommit Async

repository.getHeadCommit().then(function(commit) {
  // Use commit
});

Retrieve the commit that HEAD is currently pointing to

Returns  
Commit  

Repository#getMasterCommit Async

repository.getMasterCommit().then(function(commit) {
  // Use commit
});

Retrieve the master branch commit.

Returns  
Commit  

Repository#getNamespace Sync

var string = repository.getNamespace();
Returns  
String the active namespace, or NULL if there isn’t one

Repository#getReference Async

repository.getReference(name).then(function(reference) {
  // Use reference
});

Lookup the reference with the given name.

Parameters Type  
name String, Reference Ref name, e.g. “master”, “refs/heads/master” or Branch Ref
Returns  
Reference  

Repository#getReferenceCommit Async

repository.getReferenceCommit(name).then(function(commit) {
  // Use commit
});

Look up a refs’s commit.

Parameters Type  
name String, Reference Ref name, e.g. “master”, “refs/heads/master” or Branch Ref
Returns  
Commit  

Repository#getReferenceNames Async

repository.getReferenceNames(type).then(function(arrayString) {
  // Use arrayString
});

Lookup reference names for a repository.

Parameters Type  
type Reference.TYPE Type of reference to look up
Returns  
Array<String>  

Repository#getReferences Async

repository.getReferences().then(function(stdVectorGitReference) {
  // Use stdVectorGitReference
});
Returns  
StdVectorGitReference  

Repository#getRemote Async

repository.getRemote(remote, callback).then(function(remote) {
  // Use remote
});

Gets a remote from the repo

Parameters Type  
remote String, Remote  
callback Function  
Returns  
Remote The remote object

Repository#getRemoteNames Async

repository.getRemoteNames(Optional).then(function(object) {
  // Use object
});

Lists out the remotes in the given repository.

Parameters Type  
Optional Function callback
Returns  
Object Promise object.

Repository#getRemotes Async

repository.getRemotes().then(function(stdVectorGitRemote) {
  // Use stdVectorGitRemote
});
Returns  
StdVectorGitRemote  

Repository#getStatus Async

repository.getStatus(opts).then(function(arrayStatusFile) {
  // Use arrayStatusFile
});

Get the status of a repo to it’s working directory

Parameters Type  
opts obj  
Returns  
Array<StatusFile>  

Repository#getStatusExt Async

repository.getStatusExt(opts).then(function(arrayStatusFile) {
  // Use arrayStatusFile
});

Get extended statuses of a repo to it’s working directory. Status entries have status, headToIndex delta, and indexToWorkdir deltas

Parameters Type  
opts obj  
Returns  
Array<StatusFile>  

Repository#getSubmoduleNames Async

repository.getSubmoduleNames().then(function(arrayString) {
  // Use arrayString
});

Get the names of the submodules in the repository.

Returns  
Array<String>  

Repository#getSubmodules Async

repository.getSubmodules().then(function(stdVectorGitSubmodule) {
  // Use stdVectorGitSubmodule
});
Returns  
StdVectorGitSubmodule  

Repository#getTag Async

repository.getTag(String).then(function(tag) {
  // Use tag
});

Retrieve the tag represented by the oid.

Parameters Type  
String String, Oid sha or Oid
Returns  
Tag  

Repository#getTagByName Async

repository.getTagByName(Short).then(function(tag) {
  // Use tag
});

Retrieve the tag represented by the tag name.

Parameters Type  
Short String or full tag name
Returns  
Tag  

Repository#getTree Async

repository.getTree(String).then(function(tree) {
  // Use tree
});

Retrieve the tree represented by the oid.

Parameters Type  
String String, Oid sha or Oid
Returns  
Tree  

Repository#head Async

repository.head().then(function(reference) {
  // Use reference
});
Returns  
Reference  

Repository#headDetached Sync

var result = repository.headDetached();
Returns  
Number 1 if HEAD is detached, 0 if it’s not; error code if there
was an error.  

Repository#headDetachedForWorktree Sync

var result = repository.headDetachedForWorktree(name);
Parameters Type  
name String name of the worktree to retrieve HEAD for
Returns  
Number 1 if HEAD is detached, 0 if its not; error code if
there was an error  

Repository#headForWorktree Async

repository.headForWorktree(name).then(function(reference) {
  // Use reference
});
Parameters Type  
name String name of the worktree to retrieve HEAD for
Returns  
Reference  

Repository#headUnborn Sync

var result = repository.headUnborn();
Returns  
Number 1 if the current branch is unborn, 0 if it’s not; error
code if there was an error  

Repository#ident Sync

var string = repository.ident();
Returns  
String  

Repository#index Async

repository.index().then(function(index) {
  // Use index
});
Returns  
Index  

Repository#isApplyingMailbox Sync

var boolean = repository.isApplyingMailbox();

Returns true if the repository is in the APPLY_MAILBOX or APPLY_MAILBOX_OR_REBASE state.

Returns  
Boolean  

Repository#isBare Sync

var result = repository.isBare();
Returns  
Number 1 if the repository is bare, 0 otherwise.

Repository#isBisecting Sync

var boolean = repository.isBisecting();

Returns true if the repository is in the BISECT state.

Returns  
Boolean  

Repository#isCherrypicking Sync

var boolean = repository.isCherrypicking();

Returns true if the repository is in the CHERRYPICK state.

Returns  
Boolean  

Repository#isDefaultState Sync

var boolean = repository.isDefaultState();

Returns true if the repository is in the default NONE state.

Returns  
Boolean  

Repository#isEmpty Sync

var result = repository.isEmpty();
Returns  
Number 1 if the repository is empty, 0 if it isn’t, error code
if the repository is corrupted  

Repository#isMerging Sync

var boolean = repository.isMerging();

Returns true if the repository is in the MERGE state.

Returns  
Boolean  

Repository#isRebasing Sync

var boolean = repository.isRebasing();

Returns true if the repository is in the REBASE, REBASE_INTERACTIVE, or REBASE_MERGE state.

Returns  
Boolean  

Repository#isReverting Sync

var boolean = repository.isReverting();

Returns true if the repository is in the REVERT state.

Returns  
Boolean  

Repository#isShallow Sync

var result = repository.isShallow();
Returns  
Number 1 if shallow, zero if not

Repository#isWorktree Sync

var result = repository.isWorktree();
Returns  
Number 1 if the repository is a linked work tree, 0 otherwise.

Repository#itemPath Async

repository.itemPath(item).then(function(buf) {
  // Use buf
});
Parameters Type  
item Number The repository item for which to retrieve the path
Returns  
Buf Buffer to store the path at

Repository#mergeBranches Async

repository.mergeBranches(to, from, signature, mergePreference, mergeOptions, mergeBranchOptions).then(function(oid) {
  // Use oid
});

Merge a branch onto another branch

Parameters Type  
to String, Reference  
from String, Reference  
signature Signature  
mergePreference Merge.PREFERENCE  
mergeOptions MergeOptions  
mergeBranchOptions MergeBranchOptions  
Returns  
Oid A commit id for a succesful merge or an index for a merge with conflicts

Repository#mergeheadForeach Async

repository.mergeheadForeach(callback).then(function() {
  // method complete});
Parameters Type  
callback MergeheadForeachCb The callback function to be called on each entry

Repository#messageRemove Sync

var result = repository.messageRemove();
Returns  
Number  

Repository#odb Async

repository.odb().then(function(odb) {
  // Use odb
});
Returns  
Odb  

Repository#path Sync

var string = repository.path();
Returns  
String the path to the repository

Repository#rebaseBranches Async

repository.rebaseBranches(branch, upstream, onto, signature, beforeNextFn, beforeFinishFn, rebaseOptions).then(function(oid) {
  // Use oid
});

Rebases a branch onto another branch

Parameters Type  
branch String  
upstream String  
onto String  
signature Signature Identity of the one performing the rebase
beforeNextFn Function Callback to be called before each step of the rebase. If the callback returns a promise, the rebase will resume when the promise resolves. The rebase object is is passed to the callback.
beforeFinishFn Function Callback called before the invocation of finish(). If the callback returns a promise, finish() will be called when the promise resolves. This callback will be provided a detailed overview of the rebase
rebaseOptions RebaseOptions Options to initialize the rebase object with
Returns  
Oid A commit id for a succesful merge or an index for a rebase with conflicts

Repository#refdb Async

repository.refdb().then(function(refdb) {
  // Use refdb
});
Returns  
Refdb  

Repository#refreshIndex Async

repository.refreshIndex().then(function(index) {
  // Use index
});

Grabs a fresh copy of the index from the repository. Invalidates all previously grabbed indexes

Returns  
Index  

Repository#refreshReferences Async

repository.refreshReferences().then(function() {
  // method complete});

Repository#setHead Async

repository.setHead(refname).then(function(result) {
  // Use result
});
Parameters Type  
refname String Canonical name of the reference the HEAD should point at
Returns  
Number 0 on success, or an error code

Repository#setHeadDetached Sync

var result = repository.setHeadDetached(commitish);
Parameters Type  
commitish Oid Object id of the Commit the HEAD should point to
Returns  
Number 0 on success, or an error code

Repository#setHeadDetachedFromAnnotated Sync

var result = repository.setHeadDetachedFromAnnotated(commitish);
Parameters Type  
commitish AnnotatedCommit  
Returns  
Number  

Repository#setIdent Sync

var result = repository.setIdent(name, email);
Parameters Type  
name String the name to use for the reflog entries
email String the email to use for the reflog entries
Returns  
Number  

Repository#setIndex Sync

repository.setIndex(index);
Parameters Type  
index Index  

Repository#setNamespace Sync

var result = repository.setNamespace(nmspace);
Parameters Type  
nmspace String The namespace. This should not include the refs folder, e.g. to namespace all references under refs/namespaces/foo/, use foo as the namespace.
Returns  
Number 0 on success, -1 on error

Repository#setWorkdir Sync

var result = repository.setWorkdir(workdir, update_gitlink);
Parameters Type  
workdir String The path to a working directory
update_gitlink Number Create/update gitlink in workdir and set config “core.worktree” (if workdir is not the parent of the .git directory)
Returns  
Number 0, or an error code

Repository#stageFilemode Async

repository.stageFilemode(filePath, stageNew).then(function(number) {
  // Use number
});

Stages or unstages line selection of a specified file

Parameters Type  
filePath String, Array The relative path of this file in the repo
stageNew Boolean Set to stage new filemode. Unset to unstage.
Returns  
Number 0 or an error code

Repository#stageLines Async

repository.stageLines(filePath, selectedLines, isStaged).then(function(number) {
  // Use number
});

Stages or unstages line selection of a specified file

Parameters Type  
filePath String The relative path of this file in the repo
selectedLines Array The array of DiffLine objects selected for staging or unstaging
isStaged Boolean Are the selected lines currently staged
Returns  
Number 0 or an error code

Repository#state Sync

var result = repository.state();
Returns  
Number The state of the repository

Repository#stateCleanup Sync

var result = repository.stateCleanup();
Returns  
Number 0 on success, or error

Repository#submoduleCacheAll Sync

var result = repository.submoduleCacheAll();
Returns  
Number  

Repository#submoduleCacheClear Sync

var result = repository.submoduleCacheClear();
Returns  
Number  

Repository#treeBuilder Sync

repository.treeBuilder(tree);

Create a new tree builder.

Parameters Type  
tree Tree  

Repository#workdir Sync

var string = repository.workdir();
Returns  
String the path to the working dir, if it exists

Repository.INIT_FLAG ENUM

Flag Value
Repository.INIT_FLAG.BARE 1
Repository.INIT_FLAG.NO_REINIT 2
Repository.INIT_FLAG.NO_DOTGIT_DIR 4
Repository.INIT_FLAG.MKDIR 8
Repository.INIT_FLAG.MKPATH 16
Repository.INIT_FLAG.EXTERNAL_TEMPLATE 32
Repository.INIT_FLAG.RELATIVE_GITLINK 64

Repository.INIT_MODE ENUM

Flag Value
Repository.INIT_MODE.INIT_SHARED_UMASK 0
Repository.INIT_MODE.INIT_SHARED_GROUP 1533
Repository.INIT_MODE.INIT_SHARED_ALL 1535

Repository.ITEM ENUM

Flag Value
Repository.ITEM.GITDIR 0
Repository.ITEM.WORKDIR 1
Repository.ITEM.COMMONDIR 2
Repository.ITEM.INDEX 3
Repository.ITEM.OBJECTS 4
Repository.ITEM.REFS 5
Repository.ITEM.PACKED_REFS 6
Repository.ITEM.REMOTES 7
Repository.ITEM.CONFIG 8
Repository.ITEM.INFO 9
Repository.ITEM.HOOKS 10
Repository.ITEM.LOGS 11
Repository.ITEM.MODULES 12
Repository.ITEM.WORKTREES 13
Repository.ITEM._LAST 14

Repository.OPEN_FLAG ENUM

Flag Value
Repository.OPEN_FLAG.OPEN_NO_SEARCH 1
Repository.OPEN_FLAG.OPEN_CROSS_FS 2
Repository.OPEN_FLAG.OPEN_BARE 4
Repository.OPEN_FLAG.OPEN_NO_DOTGIT 8
Repository.OPEN_FLAG.OPEN_FROM_ENV 16

Repository.STATE ENUM

Flag Value
Repository.STATE.NONE 0
Repository.STATE.MERGE 1
Repository.STATE.REVERT 2
Repository.STATE.REVERT_SEQUENCE 3
Repository.STATE.CHERRYPICK 4
Repository.STATE.CHERRYPICK_SEQUENCE 5
Repository.STATE.BISECT 6
Repository.STATE.REBASE 7
Repository.STATE.REBASE_INTERACTIVE 8
Repository.STATE.REBASE_MERGE 9
Repository.STATE.APPLY_MAILBOX 10
Repository.STATE.APPLY_MAILBOX_OR_REBASE 11