Skip to main content
The Repository class is the main entry point for all repository operations.

Import

Static Methods

Repository.init()

Create a new repository.
Parameters: Returns: Repository instance Example:

Repository.open()

Open an existing repository.
Parameters: Returns: Repository instance Throws: NotFoundError if no repository found Example:

Repository.isRepository()

Check if a directory is a wit repository.
Example:

Instance Methods

Staging

add()

Stage files for commit.
Parameters: Example:

unstage()

Remove files from staging area.
Example:

Committing

commit()

Create a new commit.
Parameters: Options:
Returns: Commit hash Example:

Status

status()

Get repository status.
Returns:
Example:

History

log()

Get commit history.
Options:
Example:

getCommit()

Get a specific commit.
Parameters: Example:

Diffing

diff()

Get differences.
Options:
Example:

Branches

branches()

List all branches.
Returns:
Example:

currentBranch()

Get current branch name.
Returns null if in detached HEAD state.

createBranch()

Create a new branch.
Example:

deleteBranch()

Delete a branch.

switch()

Switch to a branch.
Options:
Example:

Merging

merge()

Merge a branch.
Returns:
Example:

Undo

undo()

Undo operations.
Options:
Example:

restore()

Restore file from index or commit.
Options:

Low-Level Access

getTree()

Get a tree object.

getBlob()

Get a blob (file content).

getFileContent()

Get file content from the working tree or index.

Properties

Example: Full Workflow