worktree

package
v0.0.147 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 4, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package worktree provides Git worktree management for parallel Claude Code execution. It enables running multiple Claude Code sessions in isolated worktrees, each with their own branch and working directory, while sharing repository history.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	RepoPath  string               // Path to the main repository
	BaseDir   string               // Directory for worktrees (default: .comanda-worktrees)
	Worktrees map[string]*Worktree // Active worktrees by name
	// contains filtered or unexported fields
}

Manager handles creation and cleanup of Git worktrees

func NewManager

func NewManager(repoPath string, verbose bool) (*Manager, error)

NewManager creates a new worktree manager

func (*Manager) CleanupAll

func (m *Manager) CleanupAll(removeBranches bool) error

CleanupAll removes all managed worktrees

func (*Manager) Create

func (m *Manager) Create(name, branch string) (*Worktree, error)

Create creates a new worktree from an existing branch

func (*Manager) CreateNewBranch

func (m *Manager) CreateNewBranch(name, baseBranch string) (*Worktree, error)

CreateNewBranch creates a worktree with a new branch from a base branch

func (*Manager) DiscoverExisting

func (m *Manager) DiscoverExisting() error

DiscoverExisting discovers worktrees that already exist in the base directory

func (*Manager) Get

func (m *Manager) Get(name string) *Worktree

Get returns a worktree by name

func (*Manager) GetDiff

func (m *Manager) GetDiff(name string) (string, error)

GetDiff returns the diff for a worktree (staged and unstaged changes)

func (*Manager) HasChanges

func (m *Manager) HasChanges(name string) (bool, error)

HasChanges checks if a worktree has uncommitted changes

func (*Manager) List

func (m *Manager) List() []*Worktree

List returns all active worktrees

func (*Manager) Remove

func (m *Manager) Remove(name string, removeBranch bool) error

Remove removes a worktree and optionally its branch

func (*Manager) SetBaseDir

func (m *Manager) SetBaseDir(dir string)

SetBaseDir changes the base directory for worktrees

type Worktree

type Worktree struct {
	Name   string // User-friendly name (e.g., "feature-auth")
	Branch string // Git branch name (e.g., "worktree-feature-auth")
	Path   string // Absolute path to worktree directory
}

Worktree represents a single Git worktree

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL