Repository class is the main entry point for all repository operations.
Import
Static Methods
Repository.init()
Create a new repository.| Name | Type | Description |
|---|---|---|
path | string | Directory to initialize (default: current directory) |
Repository instance
Example:
Repository.open()
Open an existing repository.| Name | Type | Description |
|---|---|---|
path | string | Repository path (default: current directory) |
Repository instance
Throws: NotFoundError if no repository found
Example:
Repository.isRepository()
Check if a directory is a wit repository.Instance Methods
Staging
add()
Stage files for commit.| Name | Type | Description |
|---|---|---|
path | string | string[] | File(s) to stage |
unstage()
Remove files from staging area.Committing
commit()
Create a new commit.| Name | Type | Description |
|---|---|---|
message | string | Commit message |
options | CommitOptions | Optional settings |
Status
status()
Get repository status.History
log()
Get commit history.getCommit()
Get a specific commit.| Name | Type | Description |
|---|---|---|
ref | string | Commit hash or reference |
Diffing
diff()
Get differences.Branches
branches()
List all branches.currentBranch()
Get current branch name.null if in detached HEAD state.
createBranch()
Create a new branch.deleteBranch()
Delete a branch.switch()
Switch to a branch.Merging
merge()
Merge a branch.Undo
undo()
Undo operations.restore()
Restore file from index or commit.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
| Property | Type | Description |
|---|---|---|
path | string | Repository root path |
witDir | string | .wit directory path |
workingDir | string | Working directory path |
config | Config | Repository configuration |
journal | Journal | Operation journal (for undo) |