Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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.