2017-01-20 6 views
0

アスタリスクのない同等のもので置き換えることのできない用途はありますか?.gitignoreのパスマッチング構文でアスタリスク "** /"が重複していますか?

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://git-scm.com/docs/gitignore#_pattern_format

私は唯一の大手アスタリスク/スラッシュ冗長性について尋ねてることを、私が指摘してみましょう。

# NuGet Packages 

# The packages folder can be ignored because of Package Restore 
**/packages/* 

# except build/, which is used as an MSBuild target. 
!**/packages/build/ 

# Uncomment if necessary however generally it will be regenerated when needed 
#!**/packages/repositories.config 

と私は、彼らは単に書くことができなかった理由は、思ったんだけど:任意の**/foo/barは、例えば、単純なfoo/bar

に置き換えることができるので、私は私の.gitignoreファイルに次き

# NuGet Packages 

# The packages folder can be ignored because of Package Restore 
packages/* 

# except build/, which is used as an MSBuild target. 
!packages/build/ 

# Uncomment if necessary however generally it will be regenerated when needed 
#!packages/repositories.config 

https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

答えて

1

もありません。.. **/fooの/バーは/ fooの/バー

0以上に一致します

=> **は何も何も許可しません。星がなければ何も許されません。当然の

あなたが '手動**爆発' と追加ルールを追加することができます...


例:

/foo/bar => /foo/bar 

**/foo/bar => /foo/bar 
      => /x/foo/bar 
      => /x/y/foo/bar 
      => /x/foo/x/foo/bar 
+1

最悪の例として、 'foo/bar'は' **/foo/bar'と同じです。しかし、アスタリスクを使用するたびに置き換えることはできません。 ;-) – Vampire

+0

誰かが 'foo/bar'を気にします - 質問は**です** **/fooか/ foo .. :)私の例は正しいです;) –

+0

しかしそれ以外: */foo/barはfoo/barと同じですか?質問への答えはイエスであり、私は間違っています –

0

はい、大手**/組み合わせが完全に廃止され、常にすることができます抜け出す。 **/foo/barは、foo/barと全く同じです(スラッシュは付いていません)。

スラッシュで始まらないパターンの特殊な意味がわからないか、明示的にしたいと思ったので、2番目の方法は書いていないかもしれません。特別な構文について知っているのは、それがルートディレクトリ内でのみ一致すると考えることによってそれを混乱させるものではありません。しかし、あなたはこのファイルの作者に尋ねなければならないでしょう。

関連する問題