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.
create a file .gitignore in your root directory and add .env file name in that .gitignore folder.After that You must untracked the .env file from git using git rm --cached .env and following that use 1. git add. 2. git commit -m " " 3. git push -u origin master . Now your .env file is remove from github repo.
You can exclude files from the repo with a .gitignore file: http://git-scm.com/docs/gitignore.
just add .env to the .gitignore file at the root of the project.
if still, you can see the .env file in git changes, you need to prevent tracking this file from git by executing the below command
git rm --cached .env