marlon
marlon

Reputation: 7633

Why doesn't this ignore my files recursively?

In my project's root directory there are directories like 'tools':

tools/evaluate/test/
tools/evaluate2

Under test, there are some .py and .csv files. I want to ignore all files except .py, so in my .gitignore, I have this entry:

!tools/**/*.py

I want to recursively ignore all non-python files under tools. What's wrong with that?

Upvotes: 0

Views: 143

Answers (2)

BeRT2me
BeRT2me

Reputation: 13242

Two parts are needed here:

# Recursively ignore everything in tools that has an extension:
**/tools/**/*.*

# Except .py files recursively in tools:
!tools/**/*.py

Upvotes: 0

Hannon qaoud
Hannon qaoud

Reputation: 958

if the files you are trying to ignore have been already committed, you need to remove them from the staging area as well, that's done by:

git rm --cached !tools/**/*.py

check the status:

git status

add the files you want to delete to .gitignore i assume manually, i don't know of an automatic way, then finally:

git add .gitignore
git commit -m "Remove unused files"

Upvotes: 1

Related Questions