git

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add added in v0.1.2

func Add() error

Add stages all changes

func AddRemote

func AddRemote(repoDir, remoteName, url string) error

AddRemote adds a git remote

func Clone

func Clone(url, targetDir string) error

Clone clones a git repository

func Commit added in v0.1.2

func Commit(message string) error

Commit commits staged changes with the given message

func GetCurrentGithubUser added in v0.2.11

func GetCurrentGithubUser() (string, error)

GetCurrentGithubUser attempts to retrieve the GitHub username of the current user by checking SSH authentication and git configuration.

func GetRemoteURL

func GetRemoteURL() (string, error)

GetRemoteURL retrieves the git remote URL from the current directory

func GetRemoteURLFromDir added in v0.1.1

func GetRemoteURLFromDir(dir string) (string, error)

GetRemoteURLFromDir retrieves the git remote URL from the specified directory. If dir is empty, it uses the current directory.

func GetRepoRoot

func GetRepoRoot() (string, error)

GetRepoRoot returns the root directory of the git repository

func HasUncommittedChanges added in v0.1.2

func HasUncommittedChanges() (bool, error)

HasUncommittedChanges checks if there are uncommitted changes in the repository

func InitRepository added in v0.2.33

func InitRepository(dir string) error

InitRepository initializes a new git repository in the specified directory. If dir is empty, it uses the current directory.

func IsBehindRemote added in v0.2.40

func IsBehindRemote() (bool, int, error)

IsBehindRemote checks if the local branch is behind origin/main. Returns whether it's behind, how many commits behind, and any error. Uses a 5-second timeout to avoid blocking if the network is unavailable.

func IsGitRepository added in v0.1.2

func IsGitRepository() bool

IsGitRepository checks if the current directory is a git repository

func IsGitRepositoryDir added in v0.2.33

func IsGitRepositoryDir(dir string) bool

IsGitRepositoryDir checks if the specified directory is a git repository. If dir is empty, it uses the current directory.

func Pull added in v0.1.6

func Pull(repoDir string) error

Pull pulls the latest changes from the remote repository

func Push

func Push(repoDir string) error

Push pushes to the remote repository

func PushToMain added in v0.1.2

func PushToMain() error

PushToMain pushes commits to the remote repository on main branch

func RemoveRemote

func RemoveRemote(repoDir, remoteName string) error

RemoveRemote removes a git remote

func SetRemoteURL added in v0.2.33

func SetRemoteURL(dir, remoteName, url string) error

SetRemoteURL sets or updates the origin remote URL. If the remote doesn't exist, it adds it. If it exists, it updates it.

Types

type RemoteInfo

type RemoteInfo struct {
	Owner string
	Repo  string
}

RemoteInfo contains parsed information from a git remote URL

func ParseRemoteURL

func ParseRemoteURL(remoteURL string) (*RemoteInfo, error)

ParseRemoteURL parses a git remote URL and extracts the owner and repository name Supports formats: - SSH: git@github.com:owner/repo.git - HTTPS: https://github.com/owner/repo.git - HTTPS (no .git): https://github.com/owner/repo

Jump to

Keyboard shortcuts

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