Guide: settings files

.env file committed to GitHub: what to do

The check reports a .env settings file kept in the repository as “Your settings file is kept with your code”. Take it out of the repository, list it in .gitignore, and keep a .env.example with the names only. If the file held a key the check recognises, that key must also be replaced.

Last updated

What the check says

  • A file with no key it recognises. “Your settings file is kept with your code”, a low finding. It holds no secret today, but the next one added to it will be public.
  • A file with a key it recognises. The key is reported instead, with no second finding for the file. The key has been seen, so it must also be replaced, and only you can do that.
  • A file of public settings only. No finding: every setting in it carries a public prefix, so it was committed on purpose.
  • Example files. A .env.example or .env.sample documents the names and is not reported.

What to do

  • 1. Take it out of the repository. The fix does this on a copy and waits for your yes.
  • 2. List it in .gitignore. So it is not added again.
  • 3. Keep a .env.example with the names only. The names, without the values.
  • 4. Replace any key it held. The finding says where each kind of key is replaced.

What the AI is shown

Files whose names say they hold credentials, such as .env, are withheld from the model, and the job's log names each one. A key pasted into ordinary code is not caught by its file's name — that is what the night check looks for.

What the study found

Of 200 public AI-built apps the study read, 32 kept a settings (.env) file in the repository holding no secret the check recognises (read on 28 October 2026).

Free check