Git Registry
The git registry fetches event specs from a remote git repository. Useful when analytics specs are maintained in a separate repository shared across multiple apps.
Setup
version: 1
workspace: "my-company"
registry:
mode: git
remote: https://github.com/my-org/analytics-specs.git
branch: main
Pulling specs
event-spec pull
This clones or fetches the remote repository into a local cache (~/.event-spec/cache/ by default) and rebuilds the in-memory index.
See CLI — pull for the full command reference.
After pulling, all CLI commands work against the cached specs — no network required:
event-spec pull && event-spec generate web-app
branch vs ref
| Key | Default | Use it to |
|---|---|---|
branch | main | Follow a branch. Every event-spec pull moves the cache to that branch's current tip on the remote. |
ref | — | Pin the cache to an exact commit SHA or tag, so every machine and every CI run indexes the same specs. Overrides branch. |
ref is resolved against the remote, in this order:
| Looked for | Matches a ref that is |
|---|---|
refs/tags/<ref> | a tag name |
refs/remotes/origin/<ref> | a branch name on the remote |
<ref> | a commit SHA, full or abbreviated to at least 7 hex digits |
The tag comes first, which is git's own precedence for a bare name. A ref that names a branch therefore follows that branch's remote tip rather than freezing on the local copy the first clone left behind (#211) — but branch: says that more plainly, so use branch: to follow and ref: to pin.
Anything that is none of the three is rejected before anything is cloned, including HEAD, revision expressions such as main~2 or v1.4.0^{}, and fully qualified spellings such as refs/heads/main. A pin has to name something the remote has.
The cache is always left on a detached HEAD, never on a local branch, so nothing a pull checks out can go stale.
All three forms are looked up, and if any two of them resolve to different commits the pull fails and names every SHA it found, instead of picking one. The usual shape is a tag and a branch both called v1.4.0; the sharper one is a branch whose name is the 40-hex SHA of the commit you pinned, which git allows. Picking a winner silently would mean that anyone who can push a branch — even where tags and main are protected — could redirect every consumer pinned to that tag or that commit. For a tag/branch clash, set ref to the commit SHA: a SHA is the one spelling nothing pushed to the remote can shadow.
Two of the same name at the same commit is not ambiguous and resolves normally, so a release tag and a release branch on one commit are fine. Annotated tags are compared by the commit they point at, not by the tag object's own SHA.
The refusal is deliberate — a pin that could mean two commits is not a pin — but it does mean anyone who can push a ref to the tracking plan can stop your pulls, and two things follow.
If the ambiguity is a ref named after the SHA you already pinned, pinning harder cannot route around it: that ref has to be removed from the remote, which is a remote-admin action, not a config change.
And removing it is not quite enough. A pull prunes neither branches nor tags, so a cache that already holds the extra ref keeps refusing after the remote is cleaned up; finish with event-spec pull --force.
ref: is the exposed key here, including when it names a branch. A tag named main — tags are often less protected than the branch itself — is enough to block every consumer whose ref is main. The same value under branch: cannot be blocked that way, because no ambiguity check runs when ref is unset. If you follow a branch, say so with branch:.
Without ref, the first pull clones with --depth 1, which also means a single branch and no tags. A shallow clone holds only the tip of the tracked branch, which is exactly what a pinned commit or a tag is not, so setting ref clones the full history instead — the only way the pin can resolve. The costs are a slower first pull on a large tracking-plan repo, and every commit and branch of that repo on disk in the cache, where a shallow clone kept only the tip.
A ref-less cache stays shallow: fetching the tracked branch does not deepen it, and no tags are fetched. A pinned pull additionally fetches the one tag its own ref names, and nothing else — so a pin brings in the history behind that tag, and a config that names no tag brings in no tags at all.
A cache cloned before you added the pin is still shallow. When that is why a ref cannot be found, event-spec pull says so and tells you to re-clone with event-spec pull --force. It only says that when re-cloning would actually help: if the remote has no tag or branch of that name, the pull says that instead and shows you the git ls-remote command that lists what the remote does have, because re-cloning a typo just reproduces the error. Asking the remote costs a round trip, so a ref that cannot be resolved takes as long to fail as your network takes to answer — on an unreachable remote, as long as your OS's connect timeout.
Version pinning
Source configs can pin individual events to a specific version:
name: web-app
platform: web
language: typescript
events:
- ecommerce/**
version_pinning:
ecommerce/product_viewed: "1-0-0" # pin to v1 despite v2 existing
output:
path: ./src/analytics/generated
This is useful during migrations — you can test against a new version in a branch source while keeping main pinned.
Authentication
For private repositories, configure git credentials using standard git mechanisms:
# SSH (recommended)
git config --global url."git@github.com:".insteadOf "https://github.com/"
# HTTPS token
git config --global url."https://<token>@github.com/".insteadOf "https://github.com/"
The CLI reads your git config — url.*.insteadOf, core.sshCommand, credential.helper in ~/.gitconfig or the repo's .git/config all apply as usual.
GIT_* environment variables are not passed throughevent-spec pull runs git with a scrubbed environment: every GIT_* variable is removed before git starts. Configure SSH and credentials in your git config, not via environment variables.
This is deliberate. event-spec runs inside git hooks, make targets and CI steps, where an inherited GIT_DIR would retarget your own checkout. The variables that name a program for git to execute are dropped for the same reason — in those contexts the environment is often set by someone other than you. What each one controls:
GIT_SSH/GIT_SSH_COMMAND— the transport program forssh://andgit@remotes.GIT_ASKPASS— the helper git asks for a password.GIT_PROXY_COMMAND— the proxy command git runs.GIT_EXTERNAL_DIFF— the external diff driver.GIT_EXEC_PATH— the directory git loads its own subcommands from.GIT_CONFIG_COUNTwithGIT_CONFIG_KEY_n/GIT_CONFIG_VALUE_n— ad-hoc config entries, which can setcore.hooksPath.
If you authenticate through one of those variables today, the table below is the one to act on: move the setting into your git config and it is a one-line change.
| Instead of | Use |
|---|---|
GIT_SSH_COMMAND="ssh -i ~/.ssh/deploy_key", or the older GIT_SSH | git config --global core.sshCommand "ssh -i ~/.ssh/deploy_key" |
GIT_ASKPASS=/path/to/askpass | git config --global core.askPass /path/to/askpass |
GIT_PROXY_COMMAND=/path/to/proxy | git config --global core.gitProxy /path/to/proxy — applies to git:// remotes only; an HTTPS remote needs git config --global http.proxy http://host:port instead |
GIT_EXTERNAL_DIFF=/path/to/diff | git config --global diff.external /path/to/diff — never affects a pull, which only runs clone, fetch and checkout |
GIT_CONFIG_COUNT=1 with GIT_CONFIG_KEY_0=<key> / GIT_CONFIG_VALUE_0=<value> | git config --global <key> <value> |
GIT_EXEC_PATH has no git config equivalent: git accepts it only as the --exec-path option, which event-spec never passes. To run a non-default git, put it first on PATH.
The last row trades a per-process variable for a file, which is the right trade for a path or a program name. But the two common CI uses of ad-hoc config are http.extraHeader=Authorization: Bearer <token> and url.https://<token>@host/.insteadOf, and git config --global writes that token in cleartext into ~/.gitconfig, which git creates world-readable and git config --list echoes — plus your shell history. That is a longer life than the environment variable it replaced, not a shorter one. If the value is a credential, use credential.helper and let your platform's keychain hold it; the same applies to a program named by core.askPass or core.gitProxy that carries a token inline.
Every setting on this page belongs in ~/.gitconfig, or in the repo's own untracked .git/config — never in a file you commit. A repo-checked config pulled in with include.path puts these values under version control, which is the one place they must not be.
When a pull fails and any of those variables was set, event-spec names it in the error, together with that variable's replacement from the table above and a link back to this page, so a dropped GIT_SSH_COMMAND does not look like a broken key. Two values are set for you: GIT_TERMINAL_PROMPT=0, so a pull fails fast instead of blocking on a credential prompt, and GIT_ALLOW_PROTOCOL=file:git:http:https:ssh, so a registry remote: cannot select a command-executing transport such as ext::.
Cache location
The local cache defaults to ~/.event-spec/cache/<repo-hash>/. Override it with cache_dir in your workspace config:
registry:
mode: git
remote: https://github.com/my-org/analytics-specs.git
branch: main
cache_dir: ./.event-spec-cache # repo-local cache, useful for CI
You can safely delete the cache directory and re-run event-spec pull to rebuild.
CI usage
In CI, pull before codegen and validate:
- run: event-spec pull
- run: event-spec validate --strict
- run: event-spec generate web-app