Help us shape the future of Go! Take the 2026 Go Developer Survey

git

package
v3.0.0-beta.34 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidRemoteURL = errors.New("invalid remote git URL")

ErrInvalidRemoteURL is returned when a URL is not an accepted remote git URL.

View Source
var ErrNotInstalled = errors.New("git is not installed; please install git from https://git-scm.com")

ErrNotInstalled is returned when git is not found in PATH.

Functions

func AddAll

func AddAll(dir string) error

AddAll stages all files in the repository at dir.

func Clone

func Clone(url, dir, tag string) error

Clone clones url into dir. If tag is non-empty, checks out that tag or branch.

func CloneRemote

func CloneRemote(url, dir, tag string) error

CloneRemote clones the remote repository at url into dir. The URL is checked with ValidateRemoteURL and git is restricted to the https, http, ssh and git transports. If tag is non-empty, checks out that tag or branch.

func HeadHash

func HeadHash(dir string) (string, error)

HeadHash returns the short (8-character) commit hash of HEAD in dir.

func Init

func Init(dir string) error

Init initializes a new git repository at dir.

func RemoteAdd

func RemoteAdd(dir, name, url string) error

RemoteAdd adds a named remote to the repository at dir.

func ValidateRemoteURL

func ValidateRemoteURL(rawURL string) error

ValidateRemoteURL reports whether url is a remote git URL that is safe to pass to git clone. Accepted forms are https://, http://, ssh:// and git:// URLs and scp-like [user@]host:path addresses. Options (values starting with '-'), transport helpers (<transport>::<address>), file:// URLs and local paths are rejected.

Types

This section is empty.

Jump to

Keyboard shortcuts

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