git

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package git provides functions for interacting with git repositories by shelling out to the git CLI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommitDate

func CommitDate(repoPath, branch string) (time.Time, error)

CommitDate returns the author date of the latest commit on the given branch.

func CurrentBranch

func CurrentBranch(repoPath string) (string, error)

CurrentBranch returns the name of the currently checked-out branch.

func DefaultBranch

func DefaultBranch(repoPath string) (string, error)

DefaultBranch returns the default branch name (main or master) by checking what the origin HEAD points to, falling back to a local heuristic.

func DeleteLocalBranch

func DeleteLocalBranch(repoPath, branch string, force bool) error

DeleteLocalBranch deletes a local branch. If force is true, uses -D instead of -d.

func DeleteRemoteBranch

func DeleteRemoteBranch(repoPath, remote, branch string) error

DeleteRemoteBranch deletes a branch on the given remote.

func Fetch

func Fetch(repoPath, remote string) error

Fetch fetches from the given remote.

func HasRemote

func HasRemote(repoPath, remote string) bool

HasRemote returns true if the given remote exists.

func IsClean

func IsClean(repoPath string) (bool, error)

IsClean returns true if the working tree has no uncommitted changes.

func IsMerged

func IsMerged(repoPath, branch, base string) (bool, error)

IsMerged returns true if the given branch has been merged into base.

func IsRepo

func IsRepo(path string) bool

IsRepo returns true if the given path is inside a git repository.

func ListBranches

func ListBranches(repoPath string) ([]string, error)

ListBranches returns all local branch names.

func MergeAbort added in v0.2.0

func MergeAbort(repoPath string) error

MergeAbort aborts an in-progress merge, restoring the branch to its pre-merge state.

func MergeBase added in v0.2.0

func MergeBase(repoPath string, ref1, ref2 string) (string, error)

MergeBase returns the best common ancestor commit between two refs.

func MergeTree added in v0.2.0

func MergeTree(repoPath string, base, local, remote string) (string, bool, error)

MergeTree performs a three-way merge-tree between base, local, and remote tree-ish references. It returns the merge output, whether conflicts were detected, and any error. This is a read-only operation that does not modify the working tree.

func MergedBranches

func MergedBranches(repoPath, base string) ([]string, error)

MergedBranches returns local branches that have been merged into the given base branch.

func Pull added in v0.2.0

func Pull(repoPath string, strategy string) error

Pull pulls from the default remote using the given strategy. Valid strategies: "rebase", "merge", "ff-only".

func RebaseAbort added in v0.2.0

func RebaseAbort(repoPath string) error

RebaseAbort aborts an in-progress rebase, restoring the branch to its pre-rebase state.

func RemoteURL

func RemoteURL(repoPath, remote string) (string, error)

RemoteURL returns the fetch URL of the given remote (usually "origin").

func StashPop added in v0.2.0

func StashPop(repoPath string) error

StashPop applies and removes the most recent stash entry.

func StashPush added in v0.2.0

func StashPush(repoPath string, message string) error

StashPush stashes the current working tree changes with the given message.

Types

This section is empty.

Jump to

Keyboard shortcuts

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