Reynier
Reynier

Reputation: 2478

Ignore everything but specific directories using .gitignore

I need to ignore every under /src directory but not /src/BankBundle. For that in my .gitignore file I do this:

/vendor/*
/app/cache/*
/app/logs/*
/web/uploads/*
/web/bundles/*
/app/config/parameters*
.DS_Store
/src/BankBundle/Resources/public/example.html
composer.lock

/src/*
!/src/BankBundle

This isn't working because any changes I made outside /src/BankBundle less say in /src/AnBundle SmartGit recognizes as a change and then show me for COMMIT, what I'm doing wrong?

Upvotes: 0

Views: 174

Answers (1)

user456814
user456814

Reputation:

I have tried these three ignore paths in a local test repo:

/src/BankBundle/Resources/public/example.html
/src/*
!/src/BankBundle

In /src/BankBundle, there is a file hello.txt. When I run git add . and git status, the example.html file is ignored, but hello.txt is added.

So it looks like your .gitignore file is set up correctly.

Upvotes: 1

Related Questions