How to hide .env file from Github

Create a file called .gitignore in the root directory of your project (it’s possible one is already there) and add .env on its own line in the file.

Also, if you have already added it to your repository, then you will have to add the file to .gitignore as stated above and then clear Git’s cache. You can find information on that in the following answer on StackOverflow.

Leave a Comment