| layout | default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| menu_item | api | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title | Repository | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description | Version 0.4.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return_to |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sections |
|
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(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(path).then(function(repository) {
// Use repository
});| Parameters | Type | |
|---|---|---|
| path | String | the path to the repository |
| Returns | |
|---|---|
| Repository |
Repository.openBare(bare_path).then(function(repository) {
// Use repository
});| Parameters | Type | |
|---|---|---|
| bare_path | String | Direct path to the bare repository |
| Returns | |
|---|---|
| Repository |
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. |
| 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.wrapOdb(odb).then(function(repository) {
// Use repository
});| Parameters | Type | |
|---|---|---|
| odb | Odb | the object database to wrap |
| Returns | |
|---|---|
| Repository |
repository.checkoutBranch(branch, opts);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.config().then(function(config) {
// Use config
});| Returns | |
|---|---|
| Config |
repository.configSnapshot().then(function(config) {
// Use config
});| Returns | |
|---|---|
| Config |
var oid = repository.continueRebase(signature);Continues an existing rebase
| Parameters | Type | | --- | --- | --- | | signature | Signature | Identity of the one performing the rebase |
| Returns | |
|---|---|
| Oid | A commit id for a succesful merge or an index for a rebase with conflicts |
var blob = repository.createBlobFromBuffer(buffer);Create a blob from a buffer
| Parameters | Type | | --- | --- | --- | | buffer | Buffer | |
| Returns | |
|---|---|
| Blob |
repository.createBranch(name, commit, force, signature, logMessage).then(function(ref) {
// Use ref
});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 | bool | Overwrite branch if it exists | | signature | Signature | Identity to use to populate reflog | | logMessage | String | One line message to be appended to the reflog |
| Returns | |
|---|---|
| Ref |
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 | Tree, Oid, String | | | parents | Array | |
| Returns | |
|---|---|
| Oid | The oid of the commit |
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.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 |
var revWalk = repository.createRevWalk(String);Instantiate a new revision walker for browsing the Repository"s history.
See also Commit.prototype.history()
| Parameters | Type | | --- | --- | --- | | String | String, Oid | sha or Oid |
| Returns | |
|---|---|
| RevWalk |
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 |
var signature = repository.defaultSignature();Gets the default signature for the default user and now timestamp
| Returns | |
|---|---|
| Signature |
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 |
var result = repository.detachHead(signature, reflog_message);| Parameters | Type | | --- | --- | --- | | signature | Signature | The identity that will used to populate the reflog entry | | reflog_message | String | The one line long message to be appended to the reflog |
| Returns | |
|---|---|
| Number | 0 on success, GIT_EUNBORNBRANCH when HEAD points to a non existing |
| branch or an error code |
repository.fetch(remote, remoteCallbacks, set, pruneAfter);Fetches from a remote
| Parameters | Type | | --- | --- | --- | | remote | String, Remote | | | remoteCallbacks | Object, RemoteCallback | Any custom callbacks needed | | set | Bool, autoTag | the AUTO_TAG option for remote | | pruneAfter | Bool | will perform a prune after the fetch if true |
repository.fetchAll(remoteCallbacks, set, pruneAfter);Fetches from all remotes
| Parameters | Type | | --- | --- | --- | | remoteCallbacks | Object, RemoteCallback | Any custom callbacks needed | | set | Bool, autoTag | the AUTO_TAG option for remotes | | pruneAfter | Bool | will perform a prune after the fetch if true |
repository.fetchheadForeach(callback).then(function() {
// method complete});| Parameters | Type | | --- | --- | --- | | callback | FetchheadForeachCb | The callback function to be called on each entry |
repository.free();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(name).then(function(ref) {
// Use ref
});Look up a branch. Alias for getReference
| Parameters | Type | | --- | --- | --- | | name | String, Ref | Ref name, e.g. "master", "refs/heads/master" or Branch Ref |
| Returns | |
|---|---|
| Ref |
repository.getBranchCommit(name).then(function(commit) {
// Use commit
});Look up a branch's most recent commit. Alias to getReferenceCommit
| Parameters | Type | | --- | --- | --- | | name | String, Ref | Ref name, e.g. "master", "refs/heads/master" or Branch Ref |
| Returns | |
|---|---|
| Commit |
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().then(function(reference) {
// Use reference
});Gets the branch that HEAD currently points to Is an alias to head()
| Returns | |
|---|---|
| Reference |
repository.getHeadCommit().then(function(commit) {
// Use commit
});Retrieve the commit that HEAD is currently pointing to
| Returns | |
|---|---|
| Commit |
repository.getMasterCommit().then(function(commit) {
// Use commit
});Retrieve the master branch commit.
| Returns | |
|---|---|
| Commit |
var string = repository.getNamespace();| Returns | |
|---|---|
| String | the active namespace, or NULL if there isn't one |
repository.getReference(name).then(function(reference) {
// Use reference
});Lookup the reference with the given name.
| Parameters | Type | | --- | --- | --- | | name | String, Ref | Ref name, e.g. "master", "refs/heads/master" or Branch Ref |
| Returns | |
|---|---|
| Reference |
repository.getReferenceCommit(name).then(function(commit) {
// Use commit
});Look up a refs's commit.
| Parameters | Type | | --- | --- | --- | | name | String, Ref | Ref name, e.g. "master", "refs/heads/master" or Branch Ref |
| Returns | |
|---|---|
| Commit |
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(type).then(function(arrayReference) {
// Use arrayReference
});Lookup references for a repository.
| Parameters | Type | | --- | --- | --- | | type | Reference.TYPE | Type of reference to look up |
| Returns | |
|---|---|
| Array<Reference> |
var remote = repository.getRemote(remote, callback);Gets a remote from the repo
| Parameters | Type | | --- | --- | --- | | remote | String, Remote | | | callback | Function | |
| Returns | |
|---|---|
| Remote | The remote object |
var object = repository.getRemotes(Optional);Lists out the remotes in the given repository.
| Parameters | Type | | --- | --- | --- | | Optional | Function | callback |
| Returns | |
|---|---|
| Object | Promise object. |
var arrayStatusFile = repository.getStatus(opts);Get the status of a repo to it's working directory
| Parameters | Type | | --- | --- | --- | | opts | obj | |
| Returns | |
|---|---|
| Array<StatusFile> |
var arrayStatusEntry = repository.getStatusExt(opts);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<StatusEntry> |
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(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(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().then(function(reference) {
// Use reference
});| Returns | |
|---|---|
| Reference |
var result = repository.headDetached();| Returns | |
|---|---|
| Number | 1 if HEAD is detached, 0 if it's not; error code if there |
| was an error. |
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.index().then(function(index) {
// Use index
});| Returns | |
|---|---|
| Index |
var result = repository.isBare();| Returns | |
|---|---|
| Number | 1 if the repository is bare, 0 otherwise. |
var result = repository.isEmpty();| Returns | |
|---|---|
| Number | 1 if the repository is empty, 0 if it isn't, error code |
| if the repository is corrupted |
var result = repository.isShallow();| Returns | |
|---|---|
| Number | 1 if shallow, zero if not |
var oid = repository.mergeBranches(to, from);Merge a branch onto another branch
| Parameters | Type | | --- | --- | --- | | to | String, Ref | | | from | String, Ref | |
| Returns | |
|---|---|
| Oid | A commit id for a succesful merge or an index for a merge with conflicts |
var result = repository.messageRemove();| Returns | |
|---|---|
| Number |
repository.odb().then(function(odb) {
// Use odb
});| Returns | |
|---|---|
| Odb |
var string = repository.path();| Returns | |
|---|---|
| String | the path to the repository |
var oid = repository.rebaseBranches(branch, upstream, onto, signature);Rebases a branch onto another branch
| Parameters | Type | | --- | --- | --- | | branch | String | | | upstream | String | | | onto | String | | | signature | Signature | Identity of the one performing the rebase |
| Returns | |
|---|---|
| Oid | A commit id for a succesful merge or an index for a rebase with conflicts |
repository.refdb().then(function(refdb) {
// Use refdb
});| Returns | |
|---|---|
| Refdb |
repository.setHead(refname, signature, log_message).then(function(result) {
// Use result
});| Parameters | Type | | --- | --- | --- | | refname | String | Canonical name of the reference the HEAD should point at | | signature | Signature | The identity that will used to populate the reflog entry | | log_message | String | The one line long message to be appended to the reflog |
| Returns | |
|---|---|
| Number | 0 on success, or an error code |
var result = repository.setHeadDetached(commitish, signature, log_message);| Parameters | Type | | --- | --- | --- | | commitish | Oid | Object id of the Commit the HEAD should point to | | signature | Signature | The identity that will used to populate the reflog entry | | log_message | String | The one line long message to be appended to the reflog |
| Returns | |
|---|---|
| Number | 0 on success, or an error code |
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 |
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 |
var result = repository.state();| Returns | |
|---|---|
| Number | The state of the repository |
var result = repository.stateCleanup();| Returns | |
|---|---|
| Number | 0 on success, or error |
repository.treeBuilder(tree);Create a new tree builder.
| Parameters | Type | | --- | --- | --- | | tree | Tree | |
var string = repository.workdir();| Returns | |
|---|---|
| String | the path to the working dir, if it exists |
| 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 |
| Flag | Value | | --- | --- | --- | | Repository.INIT_MODE.INIT_SHARED_UMASK | 0 | | Repository.INIT_MODE.INIT_SHARED_GROUP | 1533 | | Repository.INIT_MODE.INIT_SHARED_ALL | 1535 |
| Flag | Value | | --- | --- | --- | | Repository.OPEN_FLAG.OPEN_NO_SEARCH | 1 | | Repository.OPEN_FLAG.OPEN_CROSS_FS | 2 | | Repository.OPEN_FLAG.OPEN_BARE | 4 |
| Flag | Value | | --- | --- | --- | | Repository.STATE.NONE | 0 | | Repository.STATE.MERGE | 1 | | Repository.STATE.REVERT | 2 | | Repository.STATE.CHERRYPICK | 3 | | Repository.STATE.BISECT | 4 | | Repository.STATE.REBASE | 5 | | Repository.STATE.REBASE_INTERACTIVE | 6 | | Repository.STATE.REBASE_MERGE | 7 | | Repository.STATE.APPLY_MAILBOX | 8 | | Repository.STATE.APPLY_MAILBOX_OR_REBASE | 9 |