How to .gitignore "public/images/" folder in VS Code?

Viewed 1453

I've referred to many related posts here and none of them work -- my public/images folder just not greying out like my node_modules folder does in my VS Code. The following is my folder structure:

project-folder
  |--.gitignore
  |--node_modules
  |--public
  |----images

So my .gitignore file is at the same level at my public folder. I saw the node_modules is being ignored (and greyed out) in the .gitignore file like this:

node_modules/

So I tried:

public/images/

but no luck. I also tried all of the following but none turn the images folder into grey:

 1. /public/images/
 2. /public/images
 3. public/images
 4. public/images/
 5. images
 6. images/

I also tried creating another .gitignore file under the public folder and follow the same way my node_modules is being ignored but still not working: images/. I heard that the git rm --cached may sometimes remove files from file system, so I dare not try it. Can someone give me a better advice for this? Thanks!

1 Answers

Solved the problem by issuing git rm -r --cached images at the public directory level. No physical files have been removed from the file system except the git index. The working pattern in the .gitignore file at the project root folder is:

public/images/

After issuing the above command, my images folder under public has been greyed out in my VS Code. Thanks to @LalitaCode for giving me the courage to try git rm --cached and thanks to those who were trying to help as well!

Related