6

my .gitignore file

**/target/
**/.settings/
**/.classpath
**/.project
**/.idea/
**/*.iml
**/*.log

I dont know the meaning of the '**/' at the begining

zhiping chen
  • 93
  • 1
  • 5

1 Answers1

8

The double asterisk (**) is well documented:

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.

Your case matches the first one, so this line: **/.idea/ means: ignore .idea directory in any directory within the repository. So it would match /.idea/, /foo/.idea/, /foo/bar/.idea/ etc.

1615903
  • 32,635
  • 12
  • 70
  • 99