如何 git 忽略子文件夹/子目录? [英] How to git ignore subfolders / subdirectories?

查看:54
本文介绍了如何 git 忽略子文件夹/子目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 .Net 解决方案中有很多项目.我想排除所有bin/Debug"和bin/Release"文件夹(及其内容),但仍包括bin"文件夹本身以及其中包含的任何 dll.

I have a lot of projects in my .Net solution. I would like to exclude all "bin/Debug" and "bin/Release" folders (and their contents), but still include the "bin" folder itself and any dll's contained therein.

.gitignore 带有bin/";忽略调试";和发布";文件夹,以及bin"中包含的任何 dll.文件夹.

.gitignore with "bin/" ignores "Debug" and "Release" folders, but also any dll's contained in the "bin" folder.

bin/Debugbin/Release 不排除目录,除非我将忽略模式完全限定为 Solution/Project/bin/Debug - 我不想这样做,因为我需要在我的解决方案中为每个项目包含这个完整的模式,并为添加的任何新项目添加它.

bin/Debug or bin/Release in the .gitignore file does not exclude the directories unless I fully qualify the ignore pattern as Solution/Project/bin/Debug - which I don't want to do as I will need to include this full pattern for each project in my solution, as well as add it for any new projects added.

有什么建议吗?

推荐答案

您是否尝试过通配符?

Solution/*/bin/Debug
Solution/*/bin/Release

在 1.8.2 版本的 git 中,您还可以使用 ** 通配符来匹配任何级别的子目录:

With version 1.8.2 of git, you can also use the ** wildcard to match any level of subdirectories:

**/bin/Debug/
**/bin/Release/

这篇关于如何 git 忽略子文件夹/子目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆