Teoman shipahi
Teoman shipahi

Reputation: 23132

.gitignore exception is including extra files

I have .gitignore file as:

MyCompany.MyProject.OAuth/bin/
!MyCompany.MyProject.OAuth/bin/Debug/MyCompany.MyProject.OAuth.dll

For some reason source tree showing "MyCompany.MyProject.OAuth.dll" in commit list and some other files like;

MyCompany.MyProject.OAuth/bin/Debug/AutoMapper.xml
MyCompany.MyProject.OAuth/bin/Debug/Castle.Core.xml
MyCompany.MyProject.OAuth/bin/Debug/Castle.Windsor.xml
MyCompany.MyProject.OAuth/bin/Debug/Newtonsoft.Json.xml
MyCompany.MyProject.OAuth/bin/Debug/MyCompany.MyProject.OAuth.dll
MyCompany.MyProject.OAuth/bin/Debug/MyCompany.MyProject.OAuth.dll.config

If I remove second line file ignore file it removes everything in this case (as expected). All I want is to include "MyCompany.MyProject.OAuth.dll"

It is doing a wildcard match or something? and ideas?

Upvotes: 2

Views: 131

Answers (2)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 522712

It is not possible to reinclude a file if a parent directory of that file has been excluded, q.v. this SO post from @VonC.

So what you should have done is this:

MyCompany.MyProject.OAuth/bin/**
!MyCompany.MyProject.OAuth/bin/**/
!MyCompany.MyProject.OAuth/bin/Debug/MyCompany.MyProject.OAuth.dll

The first line ignores all files inside the bin directory, recursively.
The second line excludes all folders inside the bin directory, recursively.
The third line excludes the file which you want to be able to commit.

Upvotes: 4

Teoman shipahi
Teoman shipahi

Reputation: 23132

Oh, I hate to do this. (Answer own question in 5 minutes) but all I had to include sub-folder in ignore list like;

MyCompany.MyProject.OAuth/bin/Debug

Upvotes: 0

Related Questions