使GIT忽略DLL,PDB和类似的生成文件

Mau*_*rez 7 git visual-studio

我有问题让GIT知道ingore生成的文件

以下是我要忽略的文件示例

    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
Run Code Online (Sandbox Code Playgroud)

这是.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/*
Run Code Online (Sandbox Code Playgroud)

Wil*_*ins 25

在将规则添加到.gitignore文件之前,您似乎已经提交了这些文件.Git将继续监视已经被跟踪的文件.

您需要在删除这些文件的位置进行提交,然后应该忽略它们.

编辑:要递归删除文件夹及其内容,请使用git rm -r,例如:

git rm -r "./BLLTarifario/bin/"
Run Code Online (Sandbox Code Playgroud)

你需要为每个都这样做bin,并obj要删除的目录.

(可选)您可以删除文件夹(因为它们将在编译时重建)并git add -A再次运行以暂存已删除的更改.请参阅:暂存已删除的文件

由于我只需要从REPO中删除它,我为每个文件运行此命令

git rm --cached BLLTarifario/bin/Debug/BLLTarifario.dll
Run Code Online (Sandbox Code Playgroud)

最后的.gitignore文件是这样的

*.cache
*.dll
*.exe
*.pdb
/build/
*.suo
*.user
_ReSharper.*/
*.sdf
*.opensdf
*.tlog
*.log
TestResult.xml
*.VisualState.xml
Version.cs
Version.h
Version.cpp
Run Code Online (Sandbox Code Playgroud)