tags:

views:

448

answers:

2

I want to ignore all files in my repository except those that occur in the 'bin' subdirectory. I tried adding the following to my .gitignore

*
!bin/*

This does not have the desired effect, however: I created a new file inside of bin/, but doing 'git status' still "shows nothing to commit (working directory clean)"

Any suggestions?

Thanks, Michael

+7  A: 

The only issue you have is that the bin directory itself is not matched by the bin/* pattern so git isn't even look in the bin directory.

There are two solutions that spring to mind.

.gitignore :

*
!/bin/
!bin/*

or

.gitignore :

*
!/bin/

bin/.gitignore :

!*

I prefer the second solution as the first solution won't stop ignoring files in the bin directory that are in subdirectories that aren't called bin. This may or may not matter in your situation.

Charles Bailey