How to Git ignore and remove ENV Var files already in the repository 2022

published: 08 Oct 2022

5 min read

create a .gitignore file

add the lines

# environment variables
.env
.env.local
.env.production

 

My preference is to use the following

.env
.env.* 

 

Then ensure its removed from the git repository

git rm env.local --cached
git rm env.staging --cached
git commit -m "Stopped tracking env.local, and env.staging"


How to Git ignore and remove ENV Var files already in the repository 2022 | Coding Tips And Tricks

Are we missing something?  Help us improve this article. Reach out to us.

Are you looking for other code tips?

Check out what's on in the category: javascript, git, programming
Check out what's on in the tag: javascript, git, programming

TipsAndTricksta

I love coding, I love coding tips & tricks, code snippets and javascript