Skip to content

Path mirrors

A path mirror publishes part of a repository as a separate repository. The target holds only the paths its spec selects, with history rewritten so every commit shows only those paths, and every push to the source is mirrored into it in the background.

Terminal window
neo repo path-mirror create acme/monorepo --target acme/docs --path 'docs/**'

You need admin on the source and permission to create repositories in the target’s workspace. The target is private unless you pass --visibility, and it starts as importing: the first sync builds it, then it reports ready. neo repo path-mirror show acme/monorepo acme/docs follows it.

Only the mirror writes the target. Pushes, pull requests and Git LFS uploads to it are refused; clones, fetches and LFS downloads work. To take the target over, detach it: neo repo path-mirror delete (from the source’s side) or neo repo path-mirror detach (by the target’s admin, who needs nothing on the source). A detached target keeps its history and takes pushes from then on.

  • --path GLOB: source paths to publish; a leading ! excludes.
  • --map FROM=TO: publish the paths under FROM under TO instead.
  • --branch GLOB, --tag GLOB: which refs are published. The default is the source’s default branch and no tags.
  • --message: directive (the default) publishes a commit’s Path-Mirror <target-name>: <message> line as its message, and otherwise writes the message from the touched paths; generated always writes it from the touched paths, so a source message never leaks; redact-mixed keeps a message unless its commit also touched an unpublished path; verbatim keeps them all.
  • --identity: anonymous (the default) publishes every author and committer as neosource <noreply@neosource.dev> and drops jj’s change-id header; noreply keeps their names and the change-id. Emails are never published, and commit dates are kept either way.
  • --history-start: full (all history, the default), now (start at the current tip of the first branch) or a source commit id. History before the start is not published.

Under --message directive, write one line in the commit message, at the start of the line:

Path-Mirror docs: Explain the new cache flags

docs is the target repository’s name (matched without regard to case), so each mirror reads only the line addressed to it. The first line addressed to a mirror decides. Its text, trimmed, becomes the whole public message; nothing else from the source message is published. Text that is empty, longer than 200 bytes, or holds control or invisible characters is ignored, and the message is written from the touched paths instead; a bad line never fails the mirror. A commit that changes nothing the mirror publishes has no commit in the target, so its line has no effect.

For a squash-merged pull request, put the line in the PR description, which the squash commit carries, not in the title: the squash subject appends (#N). With the merge-commit method, only the title reaches the merge commit, so put the line in the PR’s own commits.

The address is stored when the mirror is created. Renaming the target does not change it; neo repo path-mirror update … --directive-name <new-name> follows the rename, as a new generation. Only someone who can read the target may pass --directive-name.

neo builds older than --identity anonymous and --message directive cannot read mirrors created with those defaults; run neo upgrade.

neo repo path-mirror update replaces what its flags name. A changed spec (including --message, --identity or --directive-name) starts a new generation and the target is rebuilt from it in the background: commit ids change and its branches are force-moved, while clones keep what they already fetched. The rewrite is deterministic, so the same spec always gives the same commits.

Readers of the source see its mirrors (neo repo path-mirror list). A reader of the target sees that it is a path mirror, but not its source or spec unless they can also read the source.