git

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Overview

Package git wraps the git plumbing commands wt shells out to.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BranchDelete

func BranchDelete(mainDir, branch string) error

BranchDelete runs `git branch -d <branch>` in mainDir.

func DefaultBranch

func DefaultBranch(mainDir string) string

DefaultBranch returns the short name of origin's default branch (e.g. "main"), resolved from the local origin/HEAD symref. Empty if unset.

func Fetch

func Fetch(mainDir string) error

Fetch runs `git fetch origin` in mainDir.

func MainDir

func MainDir() (string, error)

MainDir resolves the main checkout root, even when the current directory is inside a linked worktree. It shells out to `git rev-parse --git-common-dir` and returns the parent of that dir.

func RefExists

func RefExists(mainDir, ref string) bool

RefExists reports whether ref resolves to a valid object in mainDir.

func WorktreeAdd

func WorktreeAdd(mainDir, dir, branch, baseRef string) error

WorktreeAdd runs `git worktree add <dir> -b <branch> <baseRef>` in mainDir.

func WorktreePrune

func WorktreePrune(mainDir string) error

WorktreePrune runs `git worktree prune` in mainDir.

func WorktreeRemove

func WorktreeRemove(mainDir, dir string) error

WorktreeRemove runs `git worktree remove <dir>` in mainDir.

Types

type Worktree

type Worktree struct {
	Path   string
	Branch string
}

Worktree is one entry from `git worktree list`: its checkout path and the branch checked out there ("(detached)" if none).

func WorktreeList

func WorktreeList(mainDir string) ([]Worktree, error)

WorktreeList returns all worktrees registered against mainDir (the main checkout included), parsed from `git worktree list --porcelain`.

Jump to

Keyboard shortcuts

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