git

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package git provides utilities for interacting with Git repositories including operations for branches, commits, and worktrees.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBranchFromDir added in v0.7.0

func GetBranchFromDir(dir string) (string, error)

GetBranchFromDir returns the current branch name for the given directory. This works correctly inside git worktrees, unlike go-git's Head() which reads the main worktree's HEAD.

Types

type Repository

type Repository struct {
	*git.Repository
	// contains filtered or unexported fields
}

Repository represents a Git repository

func Open

func Open(path string) (*Repository, error)

Open opens a Git repository at the given path

func (*Repository) AddWorktree

func (r *Repository) AddWorktree(worktreePath, branchName, baseBranch string) error

AddWorktree creates a new git worktree at worktreePath with a new branch branchName, based on baseBranch (e.g. "main"). Runs: git worktree add <worktreePath> -b <branchName> <baseBranch>

func (*Repository) CheckoutBranch

func (r *Repository) CheckoutBranch(name string) error

CheckoutBranch checks out the specified branch

func (*Repository) CreateBranch

func (r *Repository) CreateBranch(name string) error

CreateBranch creates a new branch from the current HEAD

func (*Repository) DeleteBranch

func (r *Repository) DeleteBranch(name string) error

DeleteBranch deletes a branch

func (*Repository) IsClean

func (r *Repository) IsClean() (bool, error)

IsClean checks if the working directory is clean

func (*Repository) Push

func (r *Repository) Push(remoteName string, branchName string) error

Push pushes the current branch to the remote repository

func (*Repository) RemoveWorktree

func (r *Repository) RemoveWorktree(worktreePath string) error

RemoveWorktree removes the git worktree at worktreePath. Runs: git worktree remove <worktreePath>

Jump to

Keyboard shortcuts

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