Anurag Rana
Anurag Rana

Reputation: 1466

Unable to ignore directory using gitignore

Below is my directory structure.

parent_directory
 |--.gitignore
 |--static/
 |   |--js/
 |   |   |--encoding.js
 |   |--css
 |       |--parent.css
 |--tools/
 |    |--static/
 |    |   |--js/
 |    |   |--css/
 |    |--templates/

I want to ignore outer static directory. I tries static/**/ , static/, static/** but nothing is working. Whenever I edit encoding.js 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 ./static/ folder is not tracked.

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

enter image description here enter image description here

Update 2: adding static in .gitignore file ignores the /tools/static/ directory as well which is not suppose to happen. Just the outer static directory should be ignored.

enter image description here

Upvotes: 0

Views: 1439

Answers (1)

byxor
byxor

Reputation: 6369

You need to add static to your .gitignore file.

The forward slash is stopping git from finding the directory.

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

Edit 2: The poster's criteria have changed and they only want to ignore the static folder in the root directory.

Just add /static to your .gitignore file (and remove static).

This is discussed here in another Question.

Upvotes: 1

Related Questions