2

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?

BJ Myers
  • 6,617
  • 6
  • 34
  • 50
Teoman shipahi
  • 47,454
  • 15
  • 134
  • 158

2 Answers2

4

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.

Community
  • 1
  • 1
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
  • @dubes Thanks for the upvote. VonC is a serious Git expert, easily one of the most knowledgeable people on this site. – Tim Biegeleisen May 13 '16 at 15:12
  • Loved this approach. Thanks! – Teoman shipahi May 13 '16 at 15:12
  • @TimBiegeleisen actually, on Git the most knowledgeable people would be torek (http://stackoverflow.com/users/1256452/torek) ;) As in http://stackoverflow.com/a/37152945/6309, complete with six (6!) footnotes. – VonC May 13 '16 at 21:22
0

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
Teoman shipahi
  • 47,454
  • 15
  • 134
  • 158