gitx

package
v0.0.2-beta Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Checkout

func Checkout(repoRoot, branch string) error

Checkout switches branches using `git checkout <branch>`.

func CheckoutNew

func CheckoutNew(repoRoot, name string) error

CheckoutNew creates and switches to a new branch: `git checkout -b <name>`.

func Clean

func Clean(repoRoot string, includeIgnored bool) error

Clean removes untracked files/dirs: `git clean -d -f` (+ -x if includeIgnored).

func CleanPreview

func CleanPreview(repoRoot string, includeIgnored bool) ([]string, error)

CleanPreview runs a dry-run of git clean and returns the lines that would be removed.

func Commit

func Commit(repoRoot, message string) error

Commit performs a git commit with the given message.

func CurrentBranch

func CurrentBranch(repoRoot string) (string, error)

CurrentBranch returns the current branch name (or "HEAD" if detached).

func DiffHEAD

func DiffHEAD(repoRoot, path string) (string, error)

DiffHEAD returns a unified diff between HEAD and the working tree for a single file.

func FilesInLastCommit

func FilesInLastCommit(repoRoot string) ([]string, error)

FilesInLastCommit lists file paths modified in the last commit (HEAD) compared to its first parent.

func LastCommitSummary

func LastCommitSummary(repoRoot string) (string, error)

LastCommitSummary returns short hash and subject of last commit.

func ListBranches

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

ListBranches returns local branch names and the current branch name.

func Pull

func Pull(repoRoot string) error

Pull runs `git pull` in the repository.

func PullWithOutput

func PullWithOutput(repoRoot string) (string, error)

PullWithOutput runs `git pull` and returns the raw CLI output.

func Push

func Push(repoRoot string) error

Push attempts to push the current branch. If no upstream is set, it falls back to pushing to the first remote (or origin) with -u.

func RepoRoot

func RepoRoot(path string) (string, error)

RepoRoot resolves the git repository root from a given path (or current dir).

func ResetAndClean

func ResetAndClean(repoRoot string, doReset, doClean, includeIgnored bool) error

ResetAndClean executes reset and/or clean in order.

func ResetHard

func ResetHard(repoRoot string) error

ResetHard performs `git reset --hard`.

func StageFiles

func StageFiles(repoRoot string, paths []string) error

StageFiles stages the provided file paths.

func UncommitFiles

func UncommitFiles(repoRoot string, paths []string) error

UncommitFiles removes the selected paths from the last commit by resetting their index state to HEAD^ and amending the commit. Working tree is left untouched so changes reappear as unstaged modifications.

Types

type FileChange

type FileChange struct {
	Path      string
	Staged    bool
	Unstaged  bool
	Untracked bool
	Binary    bool
	Deleted   bool
}

FileChange represents a changed file in the repo.

func ChangedFiles

func ChangedFiles(repoRoot string) ([]FileChange, error)

ChangedFiles lists files changed relative to HEAD, combining staged, unstaged, and untracked.

Jump to

Keyboard shortcuts

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