go-git

A highly extensible pure-Go implementation of Git, exposing both plumbing and porcelain operations behind a pluggable storage interface.

Library
Go
vv5.19.3
7,790 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
93 /100 Excellent
Development Activity 100
Maintenance 100
Community 72
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
89 /100 Excellent
Architecture 90
Code Quality 90
Innovation 82
Learning Curve 95

go-git is a git implementation written entirely in Go, with no dependency on the system git binary or libgit2/CGO bindings. It exposes both low-level “plumbing” primitives (object encoding, packfiles, refs) and high-level “porcelain” operations (Clone, Fetch, Push, Commit, Checkout) through an idiomatic Go API, backed by a pluggable Storer interface that supports on-disk (.git-compatible) storage, purely in-memory storage for ephemeral clones, and custom backends.

Actively maintained since 2015 and used in production by projects like Gitea, Keybase, and Pulumi, as well as CNCF projects such as Kubernetes Prow and Flux, go-git targets compatibility with real git tooling for the operations it implements, tracked openly in its COMPATIBILITY.md. It supports SSH, HTTP(S), and local file transports, GPG-signed commits/tags, and submodules, and it works transparently with an in-memory filesystem abstraction for sandboxed or embedded use cases where touching the real filesystem isn’t desirable.

What You Get

  • Plumbing + porcelain API - Direct access to low-level git objects (commits, trees, blobs, packfiles) alongside high-level porcelain calls like PlainClone, Push, and Worktree.Commit.
  • Pluggable storage backends - Ships with filesystem-backed storage that mirrors a real .git directory and in-memory storage for ephemeral or sandboxed repositories, behind a common Storer interface.
  • Multi-protocol transport - Built-in SSH, HTTP(S), and local file transport implementations for fetch/push, with an extensible transport interface for custom protocols.
  • GPG signing and verification - Native support for signing and verifying commits and tags without shelling out to gpg.
  • Submodule support - Read and update git submodules programmatically as part of a worktree.

Common Use Cases

  • CI/CD tooling - Building deployment or release tools that need to clone, inspect commit history, or tag repositories without invoking a git binary.
  • In-memory repository manipulation - Testing or sandboxing git workflows entirely in memory, without touching disk.
  • Custom git servers and proxies - Implementing git-aware services (mirrors, proxies, code-review bots) using go-git’s transport and object model.
  • Embedding git in developer tools - Powering IDE plugins, GitOps controllers, or CLI utilities (e.g. Kubernetes Prow, Flux) that need programmatic git access.

Under The Hood

Architecture The Repository struct (repository.go) wraps a storage.Storer interface and a billy.Filesystem-backed worktree. The Storer interface (storage/storer.go) composes EncodedObjectStorer, ReferenceStorer, ShallowStorer, IndexStorer, and ConfigStorer, enabling pluggable storage backends: filesystem-based storage mirroring a real .git directory (storage/filesystem, storage/filesystem/dotgit) and in-memory storage for ephemeral clones (storage/memory). The plumbing layer implements the git object model itself — hashing, object encoding/decoding, packfile and index formats, reference resolution — while porcelain-level operations (Clone, Fetch, Push, Commit, Checkout) live in top-level files such as repository.go, worktree.go, remote.go, and options.go. The transport layer abstracts protocol-specific fetch/push logic (SSH, HTTP, git, file, server) behind shared interfaces, so new transports can be added without touching porcelain code, matching the open/closed design the package’s own doc comment states as a guiding principle. If the core Storer interface changed, every storage backend and any consumer relying on EncodedObjectStorer/ReferenceStorer would break — it is the system’s central seam.

Tech Stack Pure Go with no CGO dependency; go.mod declares module github.com/go-git/go-git/v5. Key dependencies include go-git/go-billy (filesystem abstraction used for both real and in-memory worktrees), go-git/gcfg (git config file parsing), ProtonMail/go-crypto (OpenPGP signing/verification), pjbgf/sha1cd (collision-detecting SHA-1), kevinburke/ssh_config, xanzy/ssh-agent, skeema/knownhosts and gliderlabs/ssh (SSH transport), elazarl/goproxy and armon/go-socks5 (proxy support), sergi/go-diff (diffing), and golang.org/x/{crypto,net,sys,text}. There is no database dependency — git repositories are the storage domain itself. Builds and tests run through the standard Go toolchain, with GitHub Actions workflows covering unit tests, CodeQL static analysis, PR validation, and a dedicated workflow that exercises compatibility against real git binaries.

Code Quality The repository carries roughly as many test files as source files (193 _test.go files against 282 non-test files), with some suites — repository_test.go, worktree_test.go, worktree_commit_test.go, remote_test.go — running well over 60KB each, indicating deep behavioral coverage. Tests combine the standard library’s testing package with stretchr/testify assertions and gopkg.in/check.v1 for table/suite-style tests. Errors are declared as explicit, exported sentinel values (e.g. ErrBranchExists, ErrRepositoryNotExists) rather than panics or opaque strings, and interfaces (Storer, EncodedObjectStorer, billy.Filesystem) are used throughout to keep components swappable and testable, backed by shared conformance test suites under storage/test.

API Design go-git’s public API mirrors familiar git porcelain verbs — PlainClone, PlainOpen, Worktree.Commit, Worktree.Checkout, Repository.Push — so developers already comfortable with the git CLI face little conceptual overhead. Struct-based option types (CloneOptions, CommitOptions, PushOptions in options.go) keep call sites readable without long positional argument lists. A 31-file _examples/ directory covering clone, log, branching, tagging, submodules, in-memory storage, and custom transports meaningfully lowers onboarding friction, and exported types carry consistent GoDoc comments throughout. The one added conceptual step beyond a single “repo handle” is understanding the Storer/Filesystem split — a Storer for objects and refs, a separate billy.Filesystem for worktree files — which is an unavoidable cost of the library’s pluggable-backend design.

Used by 18 apps in this directory

Go
85%
Apache 2.0

Argo Workflows

Data Engineering · Devops

17,029

The most popular Kubernetes-native workflow engine for orchestrating containerized DAGs, ML pipelines, CI/CD, and parallel batch jobs at scale.

View details
96
Repo Health
90
Technical
68
Dependency
Built with
Go 85%
TypeScript 11%
Updated yesterday
Go
75%
AGPL 3.0

Coder

Code Editors · Developer Tools · Devops

16,920

Self-hosted cloud development environments and AI coding agents — defined in Terraform, connected via WireGuard, automatically shut down when idle.

View details
91
Repo Health
90
Technical
66
Dependency
Built with
Go 75%
TypeScript 23%
Updated today
Go
99%
Other

Crush

AI Assistants · AI Code Assistants · Developer Tools

28,579

Your terminal coding companion — wire up any LLM with LSP intelligence, MCP extensibility, and a skills system that learns your workflow.

View details
87
Repo Health
86
Technical
68
Dependency
Built with
Go 99%
Updated today
Go
75%
MIT

Digger

Automation · Developer Tools · Devops

5,047

Run Terraform and OpenTofu natively inside your existing CI pipeline — no separate runners, no third-party secrets, no extra compute costs.

View details
78
Repo Health
73
Technical
67
Dependency
Built with
Go 75%
TypeScript 15%
Updated 3 days ago
Go
52%
AGPL 3.0

Filestash

File Storage

14,778

A self-hosted file management platform that unifies access to S3, SFTP, SMB, FTP, WebDAV, NFS, Git, SharePoint, and 20+ other storage backends through a single extensible web interface.

View details
80
Repo Health
67
Technical
67
Dependency
Built with
Go 52%
JavaScript 34%
Updated yesterday
Go
75%
Other

Flipt

Developer Tools · Devops

4,916

Git-native feature flag platform that stores, versions, and deploys feature toggles directly in your own Git repositories with no external database required.

View details
90
Repo Health
83
Technical
68
Dependency
Built with
Go 75%
TypeScript 24%
Updated yesterday
Go
83%
MIT

Gitea

Developer Tools · Devops · Project Management

58,399

Self-hosted DevOps in a single Go binary — Git hosting, GitHub Actions-compatible CI/CD, and 30+ package registries without any SaaS dependency.

View details
93
Repo Health
79
Technical
64
Dependency
Built with
Go 83%
Updated yesterday
Go
67%
MIT

hoop

Monitoring · Security

831

A wire-protocol gateway that enforces data masking, command blocking, approval workflows, and full session recording for engineers and AI agents accessing production infrastructure.

View details
86
Repo Health
80
Technical
64
Dependency
Built with
Go 67%
Clojure 15%
JavaScript 11%
Updated today
Go
97%
Apache 2.0

infracost

Developer Tools · Devops

12,560

Infracost shows cloud cost estimates for Terraform, CloudFormation, and AWS CDK before you deploy — in your terminal, editor, AI coding agent, and pull requests.

View details
82
Repo Health
78
Technical
67
Dependency
Built with
Go 97%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers