0

I have a standard asp.net MVC git ignore file where it is instructed to ignore all dll files. But in my Project, I am referencing some third party dll's. Now how can I make the gitignore to allow only this dll's and ignore other dll's.

I have seen people adding ! before the file name to exclude. But this is not working for me. I don't know why?

Actual gitignore file:

###################
# 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

At the end, I tried adding !bin/myLib.dll and !myLib.dll. This is not working.

Can somebody help me to solve this? so that I can included those dll files.

Archana
  • 75
  • 8
  • Possible duplicate: https://stackoverflow.com/questions/987142/make-gitignore-ignore-everything-except-a-few-files – fr3dch3n Nov 12 '19 at 15:20

1 Answers1

3

The order of the lines in the .gitignore matter!

The ! includes files that were previously excluded.

But your packages-ignore comes after the !/packages.


From the gitignore-documentation:

An optional prefix "!" which negates the pattern; any matching file excluded by a previous pattern will become included again.

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

fr3dch3n
  • 409
  • 3
  • 11