git

package
v0.8.34 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Git

type Git struct {
	WorkDir string
}

Git wraps the git CLI for repository operations.

func New

func New(workDir string) *Git

New creates a new Git instance for the given working directory.

func (*Git) AbortMerge

func (g *Git) AbortMerge() error

AbortMerge aborts an in-progress merge.

func (*Git) AbortRebase

func (g *Git) AbortRebase() error

AbortRebase aborts an in-progress rebase.

func (*Git) Add added in v0.8.3

func (g *Git) Add(path string) error

Add stages a file (or path) into the git index.

func (*Git) AmendNoEdit added in v0.2.7

func (g *Git) AmendNoEdit() error

AmendNoEdit amends the most recent commit without changing its message.

func (*Git) BehindCount added in v0.2.3

func (g *Git) BehindCount(remote, branch string) (int, error)

BehindCount returns the number of commits HEAD is behind remote/branch. Caller must fetch before calling this.

func (*Git) Checkout

func (g *Git) Checkout(branch string) error

func (*Git) CheckoutReset added in v0.2.11

func (g *Git) CheckoutReset(branch string) error

CheckoutReset checks out a branch, resetting it to match the remote tracking branch. This ensures the local branch is up-to-date even if the remote has advanced.

func (*Git) Commit added in v0.2.16

func (g *Git) Commit(message string) error

Commit creates a new commit with the given message.

func (*Git) ConfigureIdentity

func (g *Git) ConfigureIdentity(name, email string) error

ConfigureIdentity sets the local git user identity for commits/merges if not already set.

func (*Git) CreateBranch

func (g *Git) CreateBranch(name, from string) error

func (*Git) CurrentBranch

func (g *Git) CurrentBranch() (string, error)

func (*Git) DefaultBranch added in v0.2.3

func (g *Git) DefaultBranch() (string, error)

DefaultBranch returns the default branch name by inspecting origin/HEAD. Falls back to "main" if origin/HEAD is not set.

func (*Git) DeleteLocalBranch added in v0.2.13

func (g *Git) DeleteLocalBranch(name string) error

DeleteLocalBranch force-deletes a local branch.

func (*Git) Diff

func (g *Git) Diff(base, head string) (string, error)

func (*Git) DiffNameStatus added in v0.8.27

func (g *Git) DiffNameStatus(base, head string) ([]NameStatusEntry, error)

func (*Git) DiffNumStat added in v0.8.27

func (g *Git) DiffNumStat(base, head string) (map[string][2]int, error)

func (*Git) DiffPath added in v0.8.27

func (g *Git) DiffPath(base, head, path string) (string, error)

func (*Git) DiffPaths added in v0.8.27

func (g *Git) DiffPaths(base, head string, paths ...string) (string, error)

func (*Git) DiffStat added in v0.2.0

func (g *Git) DiffStat(base, head string) (string, error)

DiffStat returns the --stat output for changes introduced by head since its merge base with base (three-dot diff), matching the semantics of Diff.

func (*Git) Fetch

func (g *Git) Fetch(remote string) error

func (*Git) FetchRef added in v0.8.27

func (g *Git) FetchRef(remote, refspec string) error

func (*Git) ForcePush

func (g *Git) ForcePush(remote, branch string) error

func (*Git) HasConflicts

func (g *Git) HasConflicts() bool

func (*Git) HeadSHA

func (g *Git) HeadSHA() (string, error)

func (*Git) IsDirty added in v0.2.3

func (g *Git) IsDirty() (bool, error)

IsDirty returns true if the working tree has uncommitted changes (staged or unstaged, including untracked files).

func (*Git) IsMerging

func (g *Git) IsMerging() bool

IsMerging returns true if a merge is in progress (MERGE_HEAD exists).

func (*Git) Merge

func (g *Git) Merge(branch string) error

func (*Git) MergeBase added in v0.2.16

func (g *Git) MergeBase(a, b string) (string, error)

MergeBase returns the merge base commit SHA between two refs.

func (*Git) Pull

func (g *Git) Pull(remote, branch string) error

func (*Git) Push

func (g *Git) Push(remote, branch string) error

func (*Git) Rebase

func (g *Git) Rebase(onto string) error

func (*Git) ResetHead added in v0.2.7

func (g *Git) ResetHead() error

ResetHead resets the index to match HEAD, undoing any staged changes.

func (*Git) RevListCount added in v0.7.2

func (g *Git) RevListCount(rangeSpec string) (int, error)

RevListCount returns the number of commits in the given rev-list range (e.g. "<from>..<to>" or "<from>..HEAD").

func (*Git) RevParse added in v0.2.16

func (g *Git) RevParse(ref string) (string, error)

RevParse returns the SHA for a ref.

func (*Git) Rm added in v0.2.7

func (g *Git) Rm(path string) error

Rm removes a file from the git index and working tree.

func (*Git) RmDir added in v0.2.10

func (g *Git) RmDir(path string) error

RmDir removes a directory recursively from the git index and working tree. Returns nil if the path does not exist in the index.

type NameStatusEntry added in v0.8.27

type NameStatusEntry struct {
	Status  string
	Path    string
	OldPath string
}

Jump to

Keyboard shortcuts

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