I encountered this error because I once mistakenly committed .env.local
before adding it to .gitignore
. The answer to it below.
If you're facing something similar and you use the Git GUI in VSCode, just follow these steps:
.env.local
file or any file that's having this issue, copy the content to clipboard, and delete the file entirely..gitignore
file and delete the line that removes that file..env.local
file (or the file you deleted earlier in your case.).gitignore
Now, it will be ignored for real.