akd
akd

Reputation: 6758

Exclude some files with gitignore in bin folder

I have a .gitignore file that ignores anything under bin folder with the following line:

[Bb]in/

I would like to enable git to track some of the dlls under bin folder where the dll starts with a specific name

For example:

bin\Textblah1.dll
bin\Text2.dll
bin\Text4.dll
bin\anotherlib.dll

I tried ![Bb]in/Text*.dll

but it didn't work. if I change the main ignore to add * trailing

[Bb]in/*

Then it tracks all the sub folder in bin folder as well.

Is there a way to just track some of the libraries with .gitignore? or I need to add those libraries with git add ?

I have the following lines in my .gitIgnore file

[Bb]in/ ![Bb]in/Text*.dll

And now I go and add another dll in the bin folder for example : Text123.dll

I am expecting that git will recognize that new dll and it will allow me to add that new dll in the source control. However it does not. The new dll files are ignored by the git even though it matches the exclude pattern.

What am I missing?

Upvotes: 0

Views: 510

Answers (1)

ElpieKay
ElpieKay

Reputation: 30868

You almost got it.

#ignore everything under [Bb]in
[Bb]in/*
#except Text*.dll
![Bb]in/Text*.dll

Upvotes: 2

Related Questions