Documentation
¶
Overview ¶
Package git provides utilities for interacting with Git repositories including operations for branches, commits, and worktrees.
Index ¶
- func GetBranchFromDir(dir string) (string, error)
- type Repository
- func (r *Repository) AddWorktree(worktreePath, branchName, baseBranch string) error
- func (r *Repository) CheckoutBranch(name string) error
- func (r *Repository) CreateBranch(name string) error
- func (r *Repository) DeleteBranch(name string) error
- func (r *Repository) IsClean() (bool, error)
- func (r *Repository) Push(remoteName string, branchName string) error
- func (r *Repository) RemoveWorktree(worktreePath string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetBranchFromDir ¶ added in v0.7.0
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>