Search code examples
gitgitignore

Why is my subfolder not being ignored in my .gitignore?


Description

I am trying to ignore a subfolder in my project, but it doesn't seem to be working. I have a .gitignore at the root level of my project. Also at the root there is an api folder that contains a firebase folder. This is the folder I am trying to ignore. The structure is:

api/firebase/test.js

Attempts at solution

I have tried putting the following in my .gitignore at the root level:

firebase/
api/firebase/
**/api/firebase
**/firebase

And none of it works. Any help is greatly appreciated.


Solution

  • Have you tried

    api/firebase/*.js
    

    ?

    If you have already added the folder previously (as in committed it), you might need to run one of these as well:

    git rm --cached <file>
    git rm --cached api/firebase/*.js
    git rm --cached api/firebase/test.js
    

    to remove it from git's memory, else just adding the file to gitignore won't work