2017-01-20 7 views
0

별표가없는 동등 물로 대체 할 수없는 용도가 있습니까? .gitignore 경로 일치 구문에서 별표 "** /"가 중복 되나요?

https://git-scm.com/docs/gitignore#_pattern_format

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. 

나를 내가 중복을 슬래시/주요 별표에 대해 단지 부탁 해요 있다는 지적하자.

# 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는/바보다 일치하지 않을 것이다

=> **는 아무 것도 허용하지 않습니다. 별이 없으면 아무것도 허용되지 않습니다. 물론

당신이 '수동 ** 폭발'추가 규칙을 추가 할 수 있습니다 ..


예 :

/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과 동일합니다 (슬래시는 없습니다).

슬래시로 시작하지 않는 패턴의 특수한 의미를 모르기 때문에, 또는 슬래시로 시작하지 않는 패턴의 특수한 의미를 모르기 때문에 두 번째 방법으로 쓰지 않았을 수도 있습니다. 특수 구문이 루트 디렉토리에서만 일치 할 것이라고 생각하여 혼동하지 않는다는 것을 알고 있습니다. 그러나 당신은이 파일의 저자에게 물어야 할 것입니다.