git

package
v0.3.10 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

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) 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) 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) 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) 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.

Jump to

Keyboard shortcuts

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