16

I have issues convicing GIT to ingore generated files

Here is an example of the files that I want to ignore

    modified:   BLLTarifario/bin/Debug/BLLTarifario.dll
    modified:   BLLTarifario/bin/Debug/BLLTarifario.pdb
    modified:   BLLTarifario/bin/Debug/Corte.Library.dll
    modified:   BLLTarifario/bin/Debug/Corte.Library.pdb
    modified:   BLLTarifario/obj/Debug/BLLTarifario.csprojResolveAssemblyReference.cache
    modified:   BLLTarifario/obj/Debug/BLLTarifario.dll
    modified:   BLLTarifario/obj/Debug/BLLTarifario.pdb
    modified:   Corte.Library/bin/Debug/Corte.Library.dll
    modified:   Corte.Library/bin/Debug/Corte.Library.pdb
    modified:   Corte.Library/obj/Debug/Corte.Library.csprojResolveAssemblyReference.cache
    modified:   Corte.Library/obj/Debug/Corte.Library.dll
    modified:   Corte.Library/obj/Debug/Corte.Library.pdb
    modified:   Tarifario.Site/bin/BLLTarifario.dll
    modified:   Tarifario.Site/bin/BLLTarifario.pdb
    modified:   Tarifario.Site/bin/Corte.Library.dll
    modified:   Tarifario.Site/bin/Corte.Library.pdb
    modified:   Tarifario.Site/bin/Tarifario.Site.dll
    modified:   Tarifario.Site/bin/Tarifario.Site.pdb
    modified:   Tarifario.Site/obj/Debug/Tarifario.Site.csprojResolveAssemblyReference.cache
    modified:   Tarifario.Site/obj/Debug/Tarifario.Site.dll
    modified:   Tarifario.Site/obj/Debug/Tarifario.Site.pdb
    modified:   TestValidate/bin/Debug/BLLTarifario.dll
    modified:   TestValidate/bin/Debug/BLLTarifario.pdb
    modified:   TestValidate/bin/Debug/Corte.Library.dll
    modified:   TestValidate/bin/Debug/Corte.Library.pdb
    modified:   TestValidate/bin/Debug/TestValidate.exe
    modified:   TestValidate/bin/Debug/TestValidate.pdb
    modified:   TestValidate/obj/x86/Debug/TestValidate.csprojResolveAssemblyReference.cache
    modified:   TestValidate/obj/x86/Debug/TestValidate.exe
    modified:   TestValidate/obj/x86/Debug/TestValidate.pdb

And here is the .gitignore

/build/
*.suo
*.user
_ReSharper.*/
*.sdf
bin/
obj/
Debug/
Release/
*.opensdf
*.tlog
*.log
TestResult.xml
*.VisualState.xml
Version.cs
Version.h
Version.cpp
*/bin/*
*/obj/*
Mauricio Gracia Gutierrez
  • 10,288
  • 6
  • 68
  • 99

3 Answers3

40

It looks like you had these files already committed before you added your rules to the .gitignore file. Git will continue to monitor files that are already being tracked.

You'll need to make a commit where you remove these files, then they should be ignored afterwards.

Edit: To remove a folder and it's contents recursively, use git rm -r, for example:

git rm -r "./BLLTarifario/bin/"

You'll need to do this for each of the bin and obj directories that you want to delete.

Optionally, you can delete the folders (since they'll be rebuilt at compile time) and run git add -A again to stage the deleted changes. See: Staging Deleted files

Since I only needed to remove them from the REPO I run this command for every single file

git rm --cached BLLTarifario/bin/Debug/BLLTarifario.dll

And the final .gitignore file is this

*.cache
*.dll
*.exe
*.pdb
/build/
*.suo
*.user
_ReSharper.*/
*.sdf
*.opensdf
*.tlog
*.log
TestResult.xml
*.VisualState.xml
Version.cs
Version.h
Version.cpp
Community
  • 1
  • 1
Will Eddins
  • 13,628
  • 5
  • 51
  • 85
3

What is the result if you put

.dll
.pdb
.cache
.exe

into your .gitignore file .

Mauricio Gracia Gutierrez
  • 10,288
  • 6
  • 68
  • 99
Bzil
  • 156
  • 5
0

It will simply ignore them, the reason why you need to perform git rm -r [/bin] is to remove the files from git tracking, simply adding them to your .gitignore file after tracking won't stop git from pushing subsequent changes to your git repository