worktree

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(repoPath string, branch string) (string, error)

Add creates a new worktree at the computed path for the given branch. Uses --guess-remote so that remote-tracking branches are automatically checked out as new local tracking branches.

func AddNewBranch

func AddNewBranch(repoPath string, branch string) (string, error)

AddNewBranch creates a new worktree with a new branch.

func Fetch

func Fetch(repoPath string) error

Fetch runs git fetch --all --prune to update remote-tracking branches.

func ListAvailableBranches

func ListAvailableBranches(repoPath string) ([]string, error)

ListAvailableBranches returns all branch names (local + remote-only, deduplicated). Remote-only branches are returned without the remote prefix (e.g. "feature-x" not "origin/feature-x").

func ListBranches

func ListBranches(repoPath string) ([]string, error)

ListBranches returns local branch names for the repo.

func ListRemoteBranches

func ListRemoteBranches(repoPath string) ([]string, error)

ListRemoteBranches returns remote-tracking branch names (e.g. "origin/feature-x").

func Remove

func Remove(repoPath string, wtPath string, force bool) error

Remove removes a worktree. If force is true, uses --force.

func WorktreePath

func WorktreePath(repoPath string, branch string) string

WorktreePath computes the path for a new worktree. Convention: <repo-parent>/<repo-name>-<branch>

Types

type Info

type Info struct {
	Path   string
	Branch string
	IsMain bool
	Bare   bool
}

Info represents a single git worktree entry.

func List

func List(repoPath string) ([]Info, error)

List returns all worktrees for the repo at repoPath.

func ParsePorcelain

func ParsePorcelain(output string) []Info

ParsePorcelain parses the output of `git worktree list --porcelain`.

Jump to

Keyboard shortcuts

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