Path mirrors
A path mirror publishes selected paths of one repository (the source) as a separate repository (the target). The target’s history is rewritten so every commit holds only those paths, and every push to the source is mirrored into it in the background. Nothing else can write to the target.
Use one to publish part of a private repository without splitting it: a docs folder that a public site builds from, an SDK or client library, or the open parts of a closed monorepo. You keep working in the source; the target follows.
The neo path mirrors reference documents every
command-line flag.
Create a path mirror
Section titled “Create a path mirror”You need admin on the source repository and permission to create repositories in the workspace the target goes into. The target can be in another workspace than the source.
- On the source repository, open Settings → Path mirrors and press New path mirror.
- Pick the Target workspace and type the Target name. The target is a new repository, so it must not exist yet.
- Fill in Paths, one glob per line, matched against source paths. A
leading
!excludes, for exampledocs/**then!docs/internal/**. - Optionally add Mappings to publish the paths somewhere else in the
target (Add mapping, then
docs/→site/). - Set Branches, Tags, Commit messages, Authors and History start, or keep the defaults. The next section says what each one exposes.
- Press Create path mirror.
From the command line, the same mirror is:
neo repo path-mirror create acme/monorepo --target acme/docs --path 'docs/**'The web form always creates the target private. The CLI does too unless you ask otherwise. Making the target public is a separate step, in the target’s Settings → General, after you have checked it (see Before making the target public).
The target starts out importing while the first sync builds it. Its code page
shows “First sync in progress” until then. When the first sync succeeds, the
target is ready and its files appear. neo repo path-mirror show acme/monorepo acme/docs reports the same status.
What gets published
Section titled “What gets published”The defaults publish as little as possible:
- the target is private;
- authors are anonymous: every author and committer is
neosource <noreply@neosource.dev>; - commit messages are directive: a commit publishes only the message its
author wrote for the mirror, otherwise a generated
Update <paths>line; - author and committer email addresses are never published, whatever you choose (addresses written in message text are covered below);
- no tags, and only the source’s default branch.
One default is wide: History start is Full history, so every past version of every published file goes out. Choose From now or From a commit when the published paths ever held something that must stay private.
| What | Default | What a looser setting exposes |
|---|---|---|
| Paths | Only paths your Paths globs select. | Every version of every selected file in the published history. A broader glob or a removed ! exclusion publishes more. |
| Mappings | None: each selected path is published where it is. | With mappings, a selected path is published only when a mapping covers it. A path no mapping covers stays private. |
| Branches | The source’s default branch. | Each matching branch, with its name and its history of the published paths. |
| Tags | None. | Each matching tag name whose commit has a published counterpart on a published branch. A commit that changed no published path counts as its parent’s counterpart, so a tag on an unpublished branch can still be published. Annotated tags become lightweight, so tag messages are never published. |
| History start | Full history: every source commit that touched a published path. | Full history publishes old file versions, including content later deleted. From now and From a commit publish nothing before the start. |
| Authors | Anonymous: neosource <noreply@neosource.dev> on every commit. |
Noreply publishes author and committer names. Emails are replaced either way. Commit dates and time zones are always kept. |
| Commit messages | Directive: the commit’s Path-Mirror line, else Update <paths>. |
Generated publishes nothing an author wrote. Redact mixed publishes the full message of every commit that touched only published paths. Verbatim publishes every message, including commits that also changed private paths. In any published message text, addresses in angle brackets are replaced, but bare addresses are kept. |
Whenever author-written text is published (a message kept under Redact
mixed or Verbatim, or a Directive line), an address in angle brackets
(<ana@example.com>, as in Co-authored-by: lines) is replaced with
noreply@neosource.dev. A bare address without brackets, such as
ana@example.com, is published as written, and so are pull request titles and
numbers, issue references and anything else in the text.
Other details of what a mirror publishes:
- Published file contents are byte-identical to the source, including symlinks (the link text) and submodule entries.
- Git LFS pointer files are published, but the LFS objects are not, so LFS-tracked files in the target have no content to download.
- Commit signatures are dropped: the rewritten commits are new commits.
- A commit’s
change-idheader (written by jj) is dropped underanonymous, because it would link a target commit to the same change in other mirrors or copies of the source that show author names. Undernoreplyit is kept as it is. Dates, file contents and history shape still let someone holding a named copy of the same commits match them. - Under the
verbatimandredact-mixedmessage modes, and underdirectivefor a commit with a directive line, the text the author wrote is published except for<…@…>spans. AChange-Id:trailer or aSigned-off-by: Real Nameline in that text is published as it is and can be searched for directly. - A reader of the target sees that it is a path mirror. They see the source’s name, the spec and the sync status only if they can also read the source.
Publication cannot be recalled. Narrowing the spec later removes content from the target’s branches, and about 24 hours after the rebuild finishes, from its storage. Until the rebuild succeeds, the old content is still stored. Clones and forks already taken keep it. To retract published history, delete the target repository.
Before making the target public
Section titled “Before making the target public”Clone the private target and check it the way an outsider would see it:
- History:
git log --all --reversestarts where you meant it to, and the number of commits is plausible. - Identities:
git log --all --format='%an <%ae> / %cn <%ce>' | sort -ushows only the identities you expect. - Messages:
git log --all --format=%Bholds nothing private, such as internal project names, customer names, PR titles, links or email addresses. - Paths:
git log --all --name-only --format= | sort -ulists no path you meant to keep private, in any commit, not only the latest. - Refs:
git ls-remoteshows only the branch and tag names you meant to publish. - It works: a fresh clone builds, or does what the project says it does.
Then change the visibility in the target’s Settings → General.
Writing a public commit message
Section titled “Writing a public commit message”Under Directive, write one line in the commit message, at the start of the line, addressed to the target by name:
Rework the cache layer for the billing service
Path-Mirror docs: Explain the new cache flagsThe target docs publishes this commit with the message
Explain the new cache flags. Nothing else from the source message goes out.
- The name is the target repository’s name, without the workspace, matched without regard to case. Lines addressed to other names are ignored, so one commit can carry a line for each mirror.
- The first line addressed to the mirror decides.
- An empty line, one longer than 200 bytes, or one with control or invisible characters is ignored, and the generated message is used. A bad line never stops the mirror.
- A commit that changes nothing the mirror publishes usually has no commit in the target, so its line has no effect. The exception is a merge with two or more published parents: it is always kept, and its line applies.
- For a squash-merged pull request, put the line in the PR description, not its
title. The squash subject gets
(#N)appended, which would then be published. With merge commits, put the line in the PR’s own commits. - Under Generated, Redact mixed and Verbatim, the line has no special meaning. The last two publish it as ordinary text.
The name is stored when the mirror is created. If the target is renamed, lines must keep using the old name until you switch to the new one: Edit the mirror and tick Use the current name. That change rebuilds the target.
The target is read-only
Section titled “The target is read-only”Only the mirror writes to the target. On the target:
- Refused: pushes, pull requests (New pull request is disabled), Git LFS uploads, and running workflows (Run workflow is disabled).
- Allowed: browsing, cloning, fetching, and issues. Git LFS download requests are accepted, but there are no LFS objects to fetch (see above).
The target’s code page carries a banner that says it is a read-only path mirror. The banner names the source only to people who can read it.
To make the target an ordinary repository, detach it. It keeps its history, neosource stops syncing it, and it takes pushes from then on. Either side can detach:
- an admin of the source, with Detach on the mirror’s row in the source’s Settings → Path mirrors;
- an admin of the target, who needs no access to the source, with Detach
from source in the target’s Settings → Danger zone, or
neo repo path-mirror detach <owner>/<target>.
Detaching cannot be undone.
Status and troubleshooting
Section titled “Status and troubleshooting”The source’s Settings → Path mirrors lists each mirror with a status:
| Status | Meaning |
|---|---|
| pending | Not synced yet: the first sync has not finished. |
| synced | Up to date with the source. |
| behind | The source has moved since the last sync; the mirror catches up in the background. |
| warning | Some configured branches are not published (below). |
| error | The last sync failed (below). |
Each row also shows when it last synced, its generation, and how many syncs in a row have failed, if any. The generation is the version of the spec the target is built from, and each change adds one.
When a sync fails, the source’s admins see the headline below and the recorded error. Admins of the target see the same headline on the target’s banner, but never the source’s name or spec unless they can read the source.
| Message | What to do |
|---|---|
| Sync paused: the source repository is unavailable | neosource cannot read the source. It keeps retrying. |
| Sync paused: storage quota exceeded | The target’s workspace is over its storage quota. Free up space or raise the quota; syncing resumes on its own. |
| The last sync failed | neosource retries automatically. What the target already shows stays as it is until a sync succeeds. |
| Some mirrored branches are not published | A configured branch does not contain the history start commit, so it is skipped. A source admin can change the branches. |
Changing a mirror
Section titled “Changing a mirror”Edit on a mirror’s row opens the same form. You can change Paths,
Mappings, Branches, Tags, Commit messages and Authors.
History start is shown but fixed in the web form. Changing it needs
neo repo path-mirror update (see the
reference).
Any change to the spec rebuilds the target, and Save changes asks first:
Starts a new generation: the target is rebuilt, commit ids change and branches are force-moved. Anything already published stays in existing clones.
The rebuild is deterministic: the same spec always gives the same commits. Saving without a change does nothing and reports “Unchanged”. If someone else changed the mirror since you opened the form, the save is refused. Press Reload to edit the current version.
On edit, leaving Branches empty stores the source’s default branch as it is when you save. A later change of the source’s default branch is not followed.