git

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package git provides git-focused subcommands for branch, status, commit, push, diff, stash, and update operations across repository batches.

Commands in this package build call.Func handlers that execute git CLI commands within each selected repository while preserving shared output semantics.

Index

Constants

View Source
const (
	// StageNone commits only what is already in the index.
	StageNone = "none"
	// StageTracked stages modifications and deletions to tracked files, like `git commit -a`.
	StageTracked = "tracked"
	// StageAll stages everything including untracked files, like `git add -A`.
	StageAll = "all"
)

Staging modes for the commit command, mirroring the three behaviors git itself provides.

View Source
const (
	// StashTracked stashes only tracked files.
	StashTracked = "tracked"
	// StashUntracked also stashes untracked files, like `git stash push -u`.
	StashUntracked = "untracked"
	// StashAll additionally stashes ignored files, like `git stash push -a`.
	StashAll = "all"
)

Stash scopes controlling which files `git stash push` captures.

View Source
const (
	// PullDefault defers to the repository's own pull configuration.
	PullDefault = "default"
	// PullFFOnly refuses to pull when a merge commit would be required.
	PullFFOnly = "ff-only"
	// PullRebase rebases local commits onto the upstream branch.
	PullRebase = "rebase"
	// PullMerge always creates a merge commit when histories diverge.
	PullMerge = "merge"
)

Pull strategies for the update command.

Variables

View Source
var AvailablePullStrategies = []string{PullDefault, PullFFOnly, PullRebase, PullMerge}

AvailablePullStrategies lists the valid values for the --pull-strategy flag.

View Source
var AvailableStageModes = []string{StageNone, StageTracked, StageAll}

AvailableStageModes lists the valid values for the --stage flag.

View Source
var AvailableStashScopes = []string{StashTracked, StashUntracked, StashAll}

AvailableStashScopes lists the valid values for the --scope flag.

Functions

func Branch added in v0.9.6

func Branch(ctx context.Context, ch output.Channel) error

Branch checks out a new branch in the given repository. Existing branches are reset unless git.branch.reset is disabled, in which case the checkout fails instead.

func Clean added in v0.11.0

func Clean(ctx context.Context, ch output.Channel) error

Clean resets any uncommitted changes, removes untracked files, and re-initializes submodules. Removal of ignored files and submodule handling are both configurable.

func Cmd

func Cmd() *cobra.Command

Cmd configures the root git command along with all subcommands and flags

func Commit added in v0.9.6

func Commit(ctx context.Context, ch output.Channel) error

Commit stages changes according to the configured staging mode, creates a commit, and optionally pushes it to the remote repository.

func Push added in v0.9.6

func Push(ctx context.Context, ch output.Channel) error

Push committed changes to the remote repository.

func StashPop added in v0.11.0

func StashPop(ctx context.Context, ch output.Channel) error

StashPop restores the most recently stashed changes if it's a batch-tool stash. Checks viper context to determine if changes were stashed by StashPush. Returns an error if changes were expected to be stashed but cannot be popped.

func StashPush added in v0.11.0

func StashPush(ctx context.Context, ch output.Channel) error

StashPush saves uncommitted changes to the stash stack with a timestamped message. If the worktree is clean, it reports success without error. Saves whether changes were stashed for each repository to the viper context for later retrieval.

func Status added in v0.9.6

func Status(ctx context.Context, ch output.Channel) error

Status shows the git status for the given repository.

func Update added in v0.9.6

func Update(ctx context.Context, ch output.Channel) error

Update checks out the default branch and pulls the latest changes.

func ValidateBranch added in v0.10.0

func ValidateBranch(branch ...string) call.Func

ValidateBranch returns an error if the current git branch is the default branch. If a branch name is provided, it checks against that branch instead.

func ValidateStash added in v0.11.0

func ValidateStash(ctx context.Context, ch output.Channel) error

ValidateStash checks if there is a batch-tool stash to pop. It returns an error if no suitable stash is found.

Types

This section is empty.

Jump to

Keyboard shortcuts

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