如何使gitignore允许某些文件?

我有一个标准的asp.net MVC git忽略文件,该文件被指示忽略所有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文件。

kevin1985108 回答:如何使gitignore允许某些文件?

.gitignore中的行顺序很重要!

!包含先前已排除的文件。

但是您的packages忽略是在!/packages之后。


来自 gitignore -文档:

  

可选的前缀“!”否定了模式;任何匹配的文件   被先前模式排除的对象将再次包含在内。

https://git-scm.com/docs/gitignore

本文链接:https://www.f2er.com/3116574.html

大家都在问