worktree¶

For git-worktree(1).

Overview¶

Manage git worktrees using GitWorktreeManager (collection-level) and GitWorktreeCmd (per-worktree operations).

Example¶

from libvcs.cmd.git import Git

git = Git(path='/path/to/repo')

# List all worktrees
worktrees = git.worktrees.ls()

# Add a new worktree
git.worktrees.add(path='/path/to/worktree', branch='feature-branch')

# Get a specific worktree and operate on it
wt = git.worktrees.get(worktree_path='/path/to/worktree')
wt.lock(reason='Do not delete')
wt.unlock()
wt.remove()

# Prune stale worktrees
git.worktrees.prune()

API Reference¶

class libvcs.cmd.git.GitWorktreeManager
¶

Bases: object

Traverse and manage git worktrees with ORM-like filtering via QueryList.

class libvcs.cmd.git.GitWorktreeCmd
¶

Bases: object

Run git commands targeting a specific worktree.