git

package
v0.0.0-...-6ab8661 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: BSD-3-Clause, BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindRoot

func FindRoot(dir string) (string, error)

FindRoot returns a path to the root of the current Git repository in which `dir` resides, or an error if `dir` is not inside a Git repository.

Types

type TempWorktree

type TempWorktree struct {
	// contains filtered or unexported fields
}

TempWorktree is a handle to a git worktree directory created with a reference to an existing git repository.

func NewTempWorktree

func NewTempWorktree(repoPath string, committish string) (*TempWorktree, error)

NewTempWorktree creates a worktree in a temporary directory for the git repository at the specified path with the specified committish (commit hash, short commit hash, branch name, etc.). It is designed to be used to "checkout" a git repository to a particular point without affecting the main worktree, which carries the risk of losing data/work and/or conflicting with other processes.

This function exists because go-git does not appear to have the ability to generate git worktrees; only traverse them.

func (*TempWorktree) Close

func (w *TempWorktree) Close() error

Close deletes the worktree from disk and unregisters it from git.

If a worktree is not closed, `git worktree list` will show the associated directory. If a worktree is deleted out-of-band of `git worktree remove`, `git worktree list` will still show it as registered but prunable; the list can be cleaned up with `git worktree prune`.

func (*TempWorktree) Root

func (w *TempWorktree) Root() string

Root returns the path to the root directory of the worktree.

Jump to

Keyboard shortcuts

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