.gitignore file IGNORED my .env file

I’m learning React.

So while developing a project on React, I was using some Appwrite functionalities to do the backend stuff easily.

I created a .env file and saved all the necessary keys inside it.

I was about to commit the changes when I saw that the .env file was not showing in dark grayish color, instead showing greenish color in VSCode directory structure.

I understood that .gitignore file might not be considering .env file.

When I opened it, I saw that .gitignore does not have “.env” inside it. So, I wrote it. Then refreshed the directory but it was still showing the same result.

After researching, I found out that I need to delete the .env file and then commit it again.

So, this is how I solved this problem:

  1. Copied all the content of .env file in Clipboard and deleted .env file.

  2. Created a new .env file and pasted the copied content inside it.

  3. Updated .gitignore file by adding *.env inside it (Writing .env did not work for me).

  4. Committed the changes in git

git add .
git commit -m "Removing the .env file from git"
git push origin main


Discover more from Coursity

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

Discover more from Coursity

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top