Question about .gitignore

I have a project that uses some api key, so in src folder I added a file that contains the key, I export it and import it in other place where I need that key. In my project I have .gitignore file then I have src folder and in src I have that file so in .gitignore I added /src/config.js. In my editor config appears grey just like node_modules and build folders which are also ignored.
The thing is I got an email from Git Guardian that my key is present in my repository. My project is minified so I checked those chunks and found the key in there indeed. Am I doing something wrong?

Order can matter. If you added the file with the API key to the repo before you added the file to your gitignore, then it could still end up in your repo.

You can always delete the key and the line from your gitignore, commit the result, add the line back to the gitignore, commit the result, and then try adding the key again.

1 Like

I even deleted the repo, created it again and it s still there in one of the minified chunks. I have a React app and I want to host it on github so I followed all steps which also include minifying the project.

You probably have to redo generating the minified chunks after fixing the gitignore.

I ran the same process again and it’s there. I guess I need to find a workaround since it still uses that key in the final code. I will google to see if process.env might help.

Ok I think I found a solution. For those having this issue, you can check this link out: