git

package
v0.0.0-...-87c05f3 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GitignoreTemplates = []GitignoreTemplate{
	{
		Label: "Node.js / JavaScript",
		Key:   "node",
		Content: `# Node.js
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnp/
.pnp.js
.yarn/

# Build
dist/
build/
.next/
out/

# Env
.env
.env.local
.env.*.local

# Logs
logs/
*.log

# OS
.DS_Store
Thumbs.db
`,
	},
	{
		Label: "Python",
		Key:   "python",
		Content: `# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python

# Virtualenv
venv/
env/
ENV/
.venv/

# Build / dist
build/
dist/
*.egg-info/
.eggs/

# Env
.env
.env.local

# Jupyter
.ipynb_checkpoints

# mypy / pytest
.mypy_cache/
.pytest_cache/
.coverage
htmlcov/

# OS
.DS_Store
Thumbs.db
`,
	},
	{
		Label: "Go",
		Key:   "go",
		Content: `# Go
*.exe
*.exe~
*.dll
*.so
*.dylib
*.test
*.out

# Build output
/bin/
/dist/

# Vendor
/vendor/

# Env
.env
.env.local

# OS
.DS_Store
Thumbs.db
`,
	},
	{
		Label: "Java / Kotlin",
		Key:   "java",
		Content: `# Java / Kotlin
*.class
*.jar
*.war
*.ear
*.nar
hs_err_pid*

# Build
target/
build/
out/
.gradle/
.mvn/

# IDE
.idea/
*.iml
*.iws
*.ipr
.classpath
.project
.settings/

# OS
.DS_Store
Thumbs.db
`,
	},
	{
		Label: "Rust",
		Key:   "rust",
		Content: `# Rust
/target/
Cargo.lock

# Env
.env
.env.local

# OS
.DS_Store
Thumbs.db
`,
	},
	{
		Label: "Flutter / Dart",
		Key:   "flutter",
		Content: `# Flutter / Dart
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
build/

# Android
**/android/**/gradle-wrapper.jar
**/android/.gradle
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java

# iOS
**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
**/ios/**/*.pbxuser
**/ios/**/*.perspectivev3
**/ios/**/DerivedData/
**/ios/**/.generated/
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Flutter.podspec
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/flutter_assets/
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*

# Env
.env
.env.local

# OS
.DS_Store
Thumbs.db
`,
	},
	{
		Label: "Generic / Other",
		Key:   "generic",
		Content: `# Compiled and binaries
*.o
*.a
*.out
*.exe
*.dll
*.so
*.dylib

# Environments
.env
.env.local
.env.*.local

# Logs
*.log
logs/

# Build
dist/
build/
out/

# Dependencies
vendor/
node_modules/

# IDE / Editors
.idea/
.vscode/
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# OS
.DS_Store
Thumbs.db
desktop.ini
`,
	},
}

Functions

func Add

func Add(files []string) error

Add stages specific files

func AddAll

func AddAll() error

AddAll stages all files

func AddRemote

func AddRemote(url string) (string, error)

AddRemote adds a remote origin

func Branches

func Branches() ([]string, error)

Branches returns all local branches

func ClearAllConfig

func ClearAllConfig() error

ClearAllConfig removes name, email and credentials

func ClearCredentials

func ClearCredentials() error

ClearCredentials removes stored credentials from the credential helper

func ClearGlobalEmail

func ClearGlobalEmail() error

ClearGlobalEmail removes global user.email

func ClearGlobalName

func ClearGlobalName() error

ClearGlobalName removes global user.name

func Commit

func Commit(message string) (string, error)

Commit creates a commit with the given message

func CreateBranch

func CreateBranch(name string) (string, error)

CreateBranch creates and switches to a new branch

func CurrentBranch

func CurrentBranch() string

CurrentBranch returns the current branch name

func DeleteBranch

func DeleteBranch(name string) (string, error)

DeleteBranch deletes a local branch

func GetCredentialHelper

func GetCredentialHelper() string

GetCredentialHelper returns the current credential helper

func GetRemotes

func GetRemotes() []string

GetRemotes returns configured remotes

func GitignoreExists

func GitignoreExists() bool

GitignoreExists checks if .gitignore already exists

func HasStoredCredentials

func HasStoredCredentials() bool

HasStoredCredentials checks if there are stored credentials

func Init

func Init(defaultBranch string) (string, error)

Init initializes a git repository in the current directory

func InitialCommit

func InitialCommit() (string, error)

InitialCommit stages everything and makes the first commit

func IsGitRepo

func IsGitRepo() bool

IsGitRepo checks if current directory is a git repo

func Pull

func Pull() (string, error)

Pull pulls from origin — runs interactively so git can prompt for credentials

func Push

func Push() (string, error)

Push pushes to origin on the current branch — runs interactively so git can prompt for credentials

func SaveCredentialHelper

func SaveCredentialHelper() error

SaveCredentialHelper enables git credential store so tokens are saved

func SetGlobalConfig

func SetGlobalConfig(name, email string) error

SetGlobalConfig sets global git user name and email

func ShortStatusLabel

func ShortStatusLabel(code string) string

ShortStatusLabel returns a human-readable label for a git status code

func SwitchBranch

func SwitchBranch(name string) (string, error)

SwitchBranch checks out a branch

func WriteGitignore

func WriteGitignore(content string) error

WriteGitignore creates a .gitignore file with the given content

Types

type FileStatus

type FileStatus struct {
	Name   string
	Status string // "staged", "unstaged", "untracked"
	Short  string // git short status code (M, A, D, ?)
}

FileStatus represents a file in the working tree

type GitConfig

type GitConfig struct {
	Name  string
	Email string
}

GitConfig holds user configuration

func GetGlobalConfig

func GetGlobalConfig() GitConfig

GetGlobalConfig reads the global git user config

type GitignoreTemplate

type GitignoreTemplate struct {
	Label   string
	Key     string
	Content string
}

func GetTemplate

func GetTemplate(key string) *GitignoreTemplate

GetTemplate returns a template by key

type RepoStatus

type RepoStatus struct {
	Branch    string
	Staged    []FileStatus
	Unstaged  []FileStatus
	Untracked []FileStatus
	IsRepo    bool
}

RepoStatus holds the full status of the repo

func Status

func Status() RepoStatus

Status returns the full repository status

Jump to

Keyboard shortcuts

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