Guide

How to keep .env out of git, and what to do if you committed it

A committed `.env` is one of the most common ways secrets leak. Here’s how to make sure git never picks it up, and exactly what to do if it already has.

By Anmol Sethi · Updated

01

Ignore every .env, keep the example

02

Check that git really ignores it

03

Already committed? Untrack it

04

Rotate the keys first

05

Remove it from history

06

Ignore .env in every repo

07

The one-click way: Dotvane

Try Dotvane free for 7 days. Every feature, no account.

Download for Mac

Still have a question?

Write to the developer. Every email gets a reply.

[email protected]