Skip to content
Source
Sign inSign up

Keep private files out of git

Code and repositories / Repository settings

Keep private files out of git

Your .env file and your local keys must not go into git or into a chat, but each new clone needs them. The vault keeps these files encrypted on the forge, and src writes them into each new clone.

5 min read

By default, the forge refuses a push that adds a .env file (see Keep secrets out of the repository).

You need:

1. Save a file

In your clone, run:

src vault put .env

Only you can read this file. src keeps its path from the top folder of the working tree, so .env comes back as .env.

To save a file at another path in the repository, add --path:

src vault put ~/team/api.env --path apps/api/.env

The file now comes back as apps/api/.env.

2. Share a file with your team

Give a scope:

src vault put config/dev.json --scope role:read

Everyone who can read the repository now gets config/dev.json. See Who gets a file for the other scopes.

3. Get the files in a new clone

src repo clone <owner>/<repo>

The clone comes with the vault files, each at its path. It also gets the MCP servers of the repository: see Use the servers in your local agent.

Later, run this in the clone to get the new code and the new files in one step:

src pull

src pull runs git pull, then writes the vault files, then the MCP config. If git fails, it stops before the files. To give flags to git, put them after --, for example src pull -- --rebase.

  • If src repo clone cannot write a file, it keeps the clone and tells you to run src pull in it.
  • In a clone that you made with git clone, run src vault pull to write only the files.
  • To see your files, run src vault list. To delete one, run src vault delete .env.

Tip

CI secret values never come back to a clone. To use one value in your clone and in CI, you can keep it in a vault .env file. Then src secret set -f .env --env production --host api.example.com --header Authorization sets the CI secrets from that file. See Add a secret.

4. See the files in the repository

Open the repository on the forge. The file list shows the vault files that you can read, at their paths, next to the files of git. The vault is the same on every branch, so they show on every branch and tag.

  • A lock icon: a vault file. Its badge is Personal (only you) or Shared (a role). The next column says who gets it.
  • A folder with a lock: a folder that only the vault has. The next column says "Only in the vault".
  • Vault file not used: git tracks a file at this path, so a pull does not write the vault file. Click the badge to open the vault file.

At each path, you see only the file that a pull gives you. People who are signed out, or who cannot read the vault, see no vault files.

The file list of a repository: the folder secrets is only in the vault, and .env is a vault file with the Personal badge, next to the files of git

Done

A new clone is ready to run after one src repo clone, and no secret is in git. Your team sees each shared file in the folder where it goes.

Read a file in the browser

  1. In the file list, click a vault file. Its page shows each file that you can read at this path, and the one that a pull gives you.
  2. Click Reveal to show the contents. Click Hide to hide them again.

The forge keeps a record of each Reveal, the same as for a pull. If you can delete the file, the page also has Delete.

See and delete files in the browser

You add a file, or put a new version of it, with src vault put (step 1). The REST API (PUT /api/v1/repos/<owner>/<repo>/vault/files/<scope>/<path>) and the MCP tool put_vault_file save files too. In the browser, you list, reveal and delete them.

  1. Open the Settings of the repository, then Secrets under Code.
  2. Find the file under Secret files. Shared files holds the files of a role. Personal files holds your own files.
  3. To delete a file, click Delete in its row. Then click Delete file.

Admins also see the CI secrets and environments of the repository, above Secret files.

Reference

Who gets a file

ScopeWho can read itWho can save it
user:me (the default)Only youYou, with write access
role:readEveryone who can read the repositoryWriters and admins
role:writePeople with write accessAdmins
role:adminAdminsAdmins
  • The most specific file wins. When two scopes have a file at the same path, a pull gives you your own file first. Then it gives the file of the admins, the writers and the readers, in this order.
  • Public repositories refuse role:read, because everyone who is signed in can read them.
  • Agents get role files at the role of their session. They never get personal files.

How a pull keeps your work safe

  • It never writes over a file that git tracks.
  • It never writes into the .git folder.
  • It writes over an untracked file with other content only with --force.
  • It names each file that it did not write, writes the others, and exits 1.

Limits

  • A file is at most 5 MiB.
  • Each person keeps at most 100 personal files in one repository, 20 MiB in all.