.gitignore中a /和a / *和a / **的区别? [英] The difference between a/ and a/* and a/** in .gitignore?

查看:386
本文介绍了.gitignore中a /和a / *和a / **的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




  • a


    • b


      • b1.txt

      • b2.txt


    • a1.txt

    • a2.txt


  • 。 gitignore



首先:如果我想忽略文件夹a, a / a / * a / *第二:

>我想忽略文件夹a中除文件夹b以外的所有内容,唯一的方法是:

  a / * 
!a / b /

我不知道为什么 a / ** 不能做到这一点?

 #这种方式不能除了文件夹b 
a / **
!a / b /

或者你可以告诉我如何使用 a / **

解决方案

** 匹配任意数量的目录, * 只有一个。

所以如果你e。 G。忽略 / a / ** / d / ,然后 / a / b / d / / a / b / c / d / 都被忽略。

如果你e。 G。忽略 / a / * / d / ,则 / a / b / d / c> / a / b / c / d /
不会被忽略。

如果文件夹被忽略,那么Git甚至不会查看其内容来检查包含。这就是为什么你不能忽略 / a / 然后包含 / a / b / ,因为Git甚至没有看成 / a / 。因此,您必须改用 / a / * 忽略 / a / 中的所有内容,然后包含 / a / b / 忽略 / a / 中的所有内容,除了 / a / b的所有内容/


Here is my file folder.

  • a
    • b
      • b1.txt
      • b2.txt
    • a1.txt
    • a2.txt
  • .gitignore

Firstly:

I found if I wanna ignore the folder a, a/ and a/* and a/** all can complete.

Secondly:

I wanna ignore all the things in folder a except the folder b, the only way to do this is :

a/*
!a/b/

I don't know why a/** can't do this?

# this way can't except folder b
a/**
!a/b/

Or you can tell me how can I use a/** ?

解决方案

** matches any amount of directories, * only one.
So if you e. g. ignore /a/**/d/, then /a/b/d/ and /a/b/c/d/ both are ignored.
If you e. g. ignore /a/*/d/, then /a/b/d/ is ignored while /a/b/c/d/ is not ignored.

If a folder is ignored, then Git does not even look at its contents to check for inclusions. That is why you cannot ignore /a/ and then include /a/b/, as Git does not even look into /a/. Because of this you must instead ignore all contents in /a/ with /a/* and then include /a/b/ to ignore everything in /a/, except all contents of /a/b/.

这篇关于.gitignore中a /和a / *和a / **的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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