User42 User42 - 2 months ago 4x
Git Question

Unable to ignore directory using gitignore

Below is my directory structure.

| |--js/
| | |--encoding.js
| |--css
| |--parent.css
| |--static/
| | |--js/
| | |--css/
| |--templates/

I want to ignore outer static directory. I tries
but nothing is working. Whenever I edit
file it appears in tracked file list.

Steps I followed -
1. Edited the .gitignore file and added pattern [all three one at a time]

2. Edited the file encoding.js

3. checked git status. File appeared in tracked file zone.

How should I add the pattern so that any folder or file in
folder is not tracked.

Update 1: Added static in the .gitignore file. Still not working. See the attached image.

enter image description here
enter image description here


You need to add static to your .gitignore file.

The forward slash is stopping git from finding the directory.

Edit: You may need to run git rm --cached static if the folder is already being tracked by git.