Worktree class

A class representing a Git worktree.

A worktree is a linked working copy of a Git repository. It allows you to have multiple working directories for the same repository, each with its own branch checked out.

Annotations
  • @immutable

Constructors

Worktree.create({required Repository repo, required String name, required String path, Reference? ref})
Creates a new worktree.
Worktree.lookup({required Repository repo, required String name})
Looks up an existing worktree in repo with the provided name.
Worktree.openFromRepository({required Repository repo})
Opens the main worktree belonging to the provided repo.

Properties

hashCode int
The hash code for this object.
no setterinherited
isLocked bool
Checks if the worktree is locked.
no setter
isPrunable bool
Checks if the worktree is prunable.
no setter
isValid bool
Checks if the worktree is valid.
no setter
name String
Gets the name of the worktree.
no setter
path String
Gets the filesystem path for the worktree.
no setter
props List<Object?>
The list of properties that will be used to determine whether two instances are equal.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stringify bool?
If set to true, the toString method will be overridden to output this instance's props.
no setterinherited

Methods

free() → void
Releases memory allocated for the worktree object.
lock() → void
Locks the worktree if it is not already locked.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
prune([Set<GitWorktree>? flags]) → void
Prunes the working tree by removing its git data structures from disk.
repositoryFromWorktree() Repository
Opens the repository that belongs to this worktree.
toString() String
A string representation of this object.
unlock() → void
Unlocks a locked worktree.
validate() → void
Validates the worktree configuration.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

list(Repository repo) List<String>
Returns a list of names of linked working trees in the repository.