worktree

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package worktree orchestrates creating a new git worktree: resolving paths from config templates, branching from origin's default branch, copying env files, and installing dependencies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Branch

func Branch(cfg config.Config, name string) string

Branch substitutes {name} into cfg.BranchPattern.

func Dir

func Dir(cfg config.Config, mainDir string) string

Dir resolves the base directory (parent of all worktrees for this repo) from cfg.WorktreeDir, substituting {repo} and resolving it relative to mainDir.

func List

func List(mainDir string, w io.Writer) error

List prints every worktree registered against mainDir (the main checkout included) as a two-column, alignment-padded table: branch first, path second.

func New

func New(cfg config.Config, mainDir, name, branch string, w io.Writer) (string, error)

New creates a worktree named name (branch defaults to cfg.BranchPattern with name substituted if branch is empty), branching from origin's default branch. It copies configured env files, runs the install command unless disabled, and opens the editor unless disabled. Status messages are written to w. It returns the created worktree's path.

func Open

func Open(cfg config.Config, mainDir, name string, w io.Writer) error

Open opens the worktree named name in the configured editor — or, if name is empty, prompts the user to pick one via an interactive picker (the main checkout is offered as an option, labeled "(main)"). Status messages are written to w.

func Path

func Path(cfg config.Config, mainDir, name string) (string, error)

Path returns the worktree path for name — or, if name is empty, prompts the user to pick one via an interactive picker (the main checkout is offered as an option, labeled "(main)"). It doesn't check the path exists.

func Remove

func Remove(cfg config.Config, mainDir, name string, w io.Writer) error

Remove deletes the worktree named name — or, if name is empty, prompts the user to pick one via an interactive picker (the main checkout is never offered) — asks for confirmation, then removes the worktree and deletes its branch. Status messages are written to w.

Types

This section is empty.

Jump to

Keyboard shortcuts

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