git过滤所有名称为xxx的目录

使用背景:某项目中需要过滤所有名称为abcd的文件夹。

 

在.ignore文件中使用“abcd/”这样的方式只能过滤当前目录的abcd目录,对子目录或者更深层级的目录无效。

查资料发现可以使用这样的方法:/**/abcd。这样可以过滤掉所有名为abcd的目录,包括这些目录下的子目录和子文件。

 

参考内容:

  Two consecutive asterisks ("**") in patterns matched against full pathname may have special meaning:

  • A leading "**" followed by a slash means match in all directories. For example, "**/foo" matches file or directory "foo" anywhere, the same as pattern "foo". "**/foo/bar" matches file or directory "bar" anywhere that is directly under directory "foo".

  • A trailing "/**" matches everything inside. For example, "abc/**" matches all files inside directory "abc", relative to the location of the .gitignore file, with infinite depth.

  • A slash followed by two consecutive asterisks then a slash matches zero or more directories. For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.

  • Other consecutive asterisks are considered invalid.

 

参考文档:

  https://mirrors.edge.kernel.org/pub/software/scm/git/docs/gitignore.html

转载于:https://www.cnblogs.com/leite/p/9338538.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值