git

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateWorktree

func CreateWorktree(branch, targetDir string, createBranch bool) error

CreateWorktree creates a new worktree at targetDir for the given branch. If branch doesn't exist and createBranch is true, it will create it from current HEAD. targetDir may be relative; we create parent directories as needed.

func CreateWorktreeFromRef

func CreateWorktreeFromRef(branch, targetDir, fromRef string) error

CreateWorktreeFromRef creates a new branch from a given ref and adds a worktree. Equivalent to: git worktree add -b <branch> <path> <fromRef>

func DefaultWorktreeDir

func DefaultWorktreeDir(branch string) string

DefaultWorktreeDir suggests a directory name for a branch under .worktrees/<branch>

func ListBranches

func ListBranches() ([]string, error)

ListBranches returns local branches without the leading '*'

func RemoveWorktree

func RemoveWorktree(path string, force bool) error

RemoveWorktree removes a worktree by path. If force is true, uses --force.

Types

type Branch

type Branch struct {
	Name      string // short name without remote prefix
	IsRemote  bool
	Remote    string // e.g. "origin" if remote
	RemoteRef string // e.g. "origin/feature"
}

Branch represents a git branch, local or remote.

func ListBranchesDetailed

func ListBranchesDetailed() ([]Branch, error)

ListBranchesDetailed returns local and remote branches, with local first.

type Worktree

type Worktree struct {
	Path   string
	Branch string
	HEAD   string
	IsMain bool
}

func ListWorktrees

func ListWorktrees() ([]Worktree, error)

ListWorktrees returns worktrees using porcelain format.

Jump to

Keyboard shortcuts

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