如何使gitignore允许某些文件?

如何使gitignore允许某些文件?,git,dll,gitignore,Git,Dll,Gitignore,我有一个标准的asp.net MVC git ignore文件,其中指示忽略所有dll文件。但在我的项目中,我引用了一些第三方dll。现在我如何使gitignore只允许这个dll而忽略其他dll呢 我看到有人在添加!在要排除的文件名之前。但这对我不起作用。我不知道为什么 实际gitignore文件: ################### # compiled source # ################### *.com *.class *.dll *.exe *.pdb *.dll.

我有一个标准的asp.net MVC git ignore文件,其中指示忽略所有dll文件。但在我的项目中,我引用了一些第三方dll。现在我如何使gitignore只允许这个dll而忽略其他dll呢

我看到有人在添加!在要排除的文件名之前。但这对我不起作用。我不知道为什么

实际gitignore文件:

###################
# compiled source #
###################
*.com
*.class
*.dll
*.exe
*.pdb
*.dll.config
*.cache
*.suo
# Include dlls if they’re in the NuGet packages directory
!/packages/*/lib/*.dll
!/packages/*/lib/*/*.dll
# Include dlls if they're in the CommonReferences directory
!*CommonReferences/*.dll
####################
# VS Upgrade stuff #
####################
UpgradeLog.XML
_UpgradeReport_Files/
###############
# Directories #
###############
bin/
obj/
TestResults/
###################
# Web publish log #
###################
*.Publish.xml
#############
# Resharper #
#############
/_ReSharper.*
*.ReSharper.*
############
# Packages #
############
# it’s better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
######################
# Logs and databases #
######################
*.log
*.sqlite
# OS generated files #
######################
.DS_Store?
ehthumbs.db
Icon?
Thumbs.db
[Bb]in
[Oo]bj
[Tt]est[Rr]esults
*.suo
*.user
*.[Cc]ache
*[Rr]esharper*
packages
NuGet.exe
_[Ss]cripts
*.exe
*.nupkg
*.ncrunchsolution
*.dot[Cc]over
/.vs
/Content
/Images
/Scripts
/Views
/favicon.ico
/Global.asax
/Web.config
最后,我尝试添加!bin/myLib.dll和!myLib.dll。这是行不通的


有人能帮我解决这个问题吗?这样我就可以包含那些dll文件。

行在.git中的顺序忽略问题

这个!包括以前排除的文件

但是你的软件包会被忽略/包裹

从gitignore文档中:

可选前缀!这否定了这种模式;任何匹配的文件 被先前模式排除的将再次被包括

可能重复: