简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM