I have a large repository containing many VS dll projects and a couple of web folders. I want to blanket ignore all the bin and obj folders generated by all the those dll projects. However I do not want to ignore the bin folder in the web folders. Here is a much simplified secenario, a list of folders may look like this:
/DllProject1
/DllProject1/someInnerNamespace
/DllProject1/properties
/DllProject1/bin
/DllProject1/bin/debug
/DllProject1/obj/
/DllProject1/obj/debug
/DllProject2
/DllProject2/someInnerNamespace
/DllProject2/properties
/DllProject2/bin
/DllProject2/bin/debug
/DllProject2/obj/
/DllProject2/obj/debug
/Web
/Web/App_Code
/Web/assets
/Web/clientBin
/Web/bin
/Web/someModule
Bearing in mind that in the real world there are many more dll projects that may be found it various levels of folder structure. I would like to use a .gitignore that would look something like this:
bin
obj
!/Web/bin
This "should" ignore all bin and obj folders where ever they appear in the rep, but "should" explicitly un-ignore the /Web/bin folder. However that doesn't appear to work, the Web/bin folder disappears anyway.
I'm not an expert with writing
.gitignorefiles, but I see several problems with your current approach. First, why are your object and binary files inside the repository in the first place? They should not be there, nor should any of your build artifacts. Instead, build into a location outside where your source code is being stored.With regard to your
.gitignorefile, the correct order is to exclude a parent folder but then include the subfolder as an exception. So, if you wanted to exclude thewebfolder but include itsbinsubfolder, you would do something like this:I'm not sure if using a blanket ignore on
binwill give you the results you want. But as I said, you should probably move your build artifacts outside of the.gitparent folder.