User42 User42 - 3 months ago 21
Git Question

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.

enter image description here
enter image description here

Answer

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.

Comments