为什么构建结果目录不在 VS .gitignore 中启动 **

Why don't the build result directories start ** in VS .gitignore

有一个标准 Visual Studio .gitignore 文件可用 here

它包括这个部分:

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/

为什么这些行不以 gitignore pattern format **/ 开头,以便搜索包括所有子目录?

相对路径(作为您的目录名称)已经在任何地方都被忽略了。

如果你创建一个结构

foo/
  bar/x.txt
bar/x.txt

(其中 x.txt 只是有非空目录的绒毛)

并有一个 .gitignore 文件只包含

bar

然后 git 将忽略两个 bar 目录。

/bar这样的绝对路径只会忽略顶级目录。 您确定您看到的是不同的行为吗?

您链接到的文档包含以下内容:

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".

(强调我的)