If you're working with Visual Studio and your .dll happens to be in a bin
folder, then you'll need to add an exception for the particular bin folder itself, before you can add the exception for the .dll file. E.g.
!SourceCode/Solution/Project/bin
!SourceCode/Solution/Project/bin/My.dll
This is because the default Visual Studio .gitignore
file includes an ignore pattern for [Bbin]/
This pattern is zapping all bin folders (and consequently their contents), which makes any attempt to include the contents redundant (since the folder itself is already ignored).
I was able to find why my file wasn't being excepted by running
git check-ignore -v -- SourceCode/Solution/Project/bin/My.dll
from a Git Bash window. This returned the [Bbin]/
pattern.