0

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?

akd
  • 6,538
  • 16
  • 70
  • 112
  • Possible duplicate of [How do I tell Git to ignore everything except a subdirectory?](https://stackoverflow.com/questions/1248570/how-do-i-tell-git-to-ignore-everything-except-a-subdirectory) – phd Oct 05 '17 at 15:43

1 Answers1

2

You almost got it.

#ignore everything under [Bb]in
[Bb]in/*
#except Text*.dll
![Bb]in/Text*.dll
ElpieKay
  • 27,194
  • 6
  • 32
  • 53
  • as I said this doesn't work. it includes all the there are sub folder in bin folder and when I put /* then those dlls in the sub folders are not ignored anymore. – akd Oct 05 '17 at 16:11
  • @akd I'm confused. You say you'd like to track some `dll` files. `![Bb]bin/Text*.dll` does make these `dll`s in the sub folders not ignored. Run `git status -u` to check if it's what you want. – ElpieKay Oct 05 '17 at 18:10
  • Inside bin folder at top root there are dll files. Such textxx.dll and inside bin folder there are other sub folders too. In those sub folders there are also dll files such textxx.dll. I just would like to track the dlls in the root bin folder not in the sub folders. When I add [Bb]in/* and ![Bb]in/Text*.dll I can see the change includes all the dlls inside bin including sub folders too. Or something is wrong that I need to clean the cache maybe. Can’t figure out. – akd Oct 05 '17 at 18:18
  • @adk Let's say the dll in the subfolder is `bin/foo/Text2.dll`. `![Bb]in/Text*.dll` excludes `bin/Text2.dll` but doesn't exclude `bin/foo/Text2.dll`. So `bin/foo/Text2.dll` should have been ignored. If you can see its changes, then I guess it had been tracked before the gitignore rule was created or it had been added by `git add -f`. The gitignore rule has no effect on tracked files. – ElpieKay Oct 05 '17 at 18:39