.gitignore and Visual Studio project: Ignore bin/D

2020-05-12 12:15发布

I have a C# Visual Studio project in a git repository. I want to ignore the contents bin/Debug directory but not the contents of the bin/Release' directory. I've added bin/Debug to my .gitignore file, but it doesn't seem to work - it is including the entire contents of the bin directory. What would the correct entry be to do this?

9条回答
Bombasti
2楼-- · 2020-05-12 12:40

Right click on those file names you want to ignore from "Git Desktop", then add them to .gitignore file. Here gitignore file will be automatically created. Check in that file to git.

查看更多
一夜七次
3楼-- · 2020-05-12 12:42

I know it is an old question, but I've decided to share my approach which excludes exactly bin/Debug, bin/Release etc.

*/**/bin/Debug
*/**/bin/Release
*/**/obj/Debug
*/**/obj/Release
查看更多
时光不老,我们不散
4楼-- · 2020-05-12 12:42

This works for me:

*.exe
*.pdb
*.manifest
*.cache

If you are using GitHub Desktop as I am using it, you can just right click the file you want to exclude or right click it and exclude by extension:

enter image description here

This will automatically generate a .gitignore file for you with the code like above. You can download GitHub Desktop here: GitHub Desktop for Windows 64-bit.

查看更多
登录 后发表回答