git, reimplemented in Apex

Git, ported to
Salesforce.

GitForce is a byte-compatible implementation of Git written entirely in Apex — repositories live inside Salesforce custom objects, driven by a Lightning Web Component UI, with real clone / fetch / push against GitHub over the Git smart-HTTP protocol.

Anonymous Apex — GitForce
// Create a repo, stage a file, commit — entirely in Apex
Id repo = GitRepo.init('hello');
GitAdd.stage(repo, 'README.md', Blob.valueOf('# hi\n'));
String sha = GitCommit.create(repo, me, me, 'first commit');

System.debug(sha);
// => 8d3c1f...  the exact SHA-1 real `git` would compute

// ...then push it to a real GitHub remote
GitRemote.push(repo, 'refs/heads/main');
✔ pushed to github.com — objects match byte-for-byte
What it does

A real Git engine, on a platform that already has the pieces

Salesforce has a database, an HTTP stack, native SHA-1, and Apex — which turns out to be just enough to host Git's content-addressable object model end to end.

🔗

Byte-compatible objects

Blobs, trees, commits and tags hash to the exact SHA-1 object IDs real Git produces — verified against the git CLI.

🗜️

Pure-Apex zlib

A hand-rolled DEFLATE decoder (fixed + dynamic Huffman, LZ77) and a stored-block encoder — so it reads and writes real zlib streams.

📦

Packfiles & deltas

Parses delta-compressed packfiles (OFS_DELTA / REF_DELTA) and encodes packs to send — the payloads real clone/fetch/push use.

🌐

Smart-HTTP transport

A pkt-line codec and smart-HTTP client talk to real Git servers. Clone a public repo into the org; push a commit back to GitHub.

🧬

Full porcelain

add · status · commit · log · branch · checkout · diff (Myers) · merge (fast-forward & 3-way with a real merge base).

🖥️

A GitHub-style UI

A Lightning app renders the repo home, file browser, commit diffs, issues, pull requests, and projects — all backed by Apex.

The load-bearing idea

"Byte-compatible" is what makes it a port, not a toy

GitForce computes the same object hash you'd get from running git on your laptop. That property is what lets it interoperate with real remotes instead of being a Git-flavored imitation — and it's checked by a harness that diffs GitForce output against fixtures generated by the real Git CLI.

Hashing the blob "hello\n" — canonical form "blob 6\0hello\n" through SHA-1:
$ git hash-object
ce013625030ba8dba906f756967f9e9ca394464a
=
GitForce (Apex)
ce013625030ba8dba906f756967f9e9ca394464a

Verified end-to-end: a live network clone of GitHub's octocat/Hello-World reproduces commit 7fd1a60b… exactly — proving the transport stack and byte-compatibility against a real remote.

Under the hood

Four layers, all in Apex

Git's content-addressable store maps cleanly onto Salesforce custom objects; the plumbing reproduces Git's canonical encoding; the transport layer speaks the wire protocol; and the surface exposes it to LWC, REST, and Flow.

Storage

  • Repository__c
  • Git_Object__c (by SHA)
  • Git_Ref__c / HEAD
  • Git_Index_Entry__c

Plumbing

  • GitSha (native SHA-1)
  • GitObjectCodec
  • object / ref stores
  • staging index

Transport

  • Zlib (inflate/deflate)
  • PktLine · Packfile
  • GitDelta resolver
  • smart-HTTP client

Surface

  • @AuraEnabled controller
  • gitForceApp LWC
  • @RestResource API
  • Invocable (Flow)

Governor limits are respected honestly — SHA-1 is native and cheap; CPU-heavy inflate runs in async jobs; the callout response cap bounds clone size. The trade-offs are documented, not hidden.

Get it

Install the managed package

GitForce ships as a namespaced (gitforce) Unlocked 2GP package. Install it into any Salesforce org:

# Salesforce CLI
sf package install --package 04tDo00000012EYIAY \
  --target-org <your-org> --wait 20 --publish-wait 20

Or open the install URL in a browser (log in to the target org first):
login.salesforce.com/packaging/installPackage.apexp?p0=04tDo00000012EYIAY

After install, open the GitForce app. To use remotes, add your own GitHub token to the packaged GitForce_GitHub Named Credential — no secret ships in the package.

Unlocked 2GP namespace: gitforce v0.1.1.1 MIT licensed API 62.0