Gitignore 不忽略父目录文件 XCode

Gitignore not ignoring parent directory files XCode

我的 XCode 项目中有以下文件夹结构:

MyProjectName
- .DS_Store
- MyProjectName
- - .gitignore
- - MyProjectName
- - MyProjectName.xcodeproj
- - MyProjectNameTests
- - MyProjectNameUITests
- MyProjectName.workspace

我的 .gitignore 文件包含以下行:

.DS_Store
SM_Familias.xcworkspace/

但是我的 git 状态命令显示了这两个文件:

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    ../.DS_Store
    ../MyProjectName.xcworkspace/xcuserdata/Rai.xcuserdatad/xcdebugger/

有没有办法忽略.git忽略文件的父目录中的文件?

Is there any way to ignore files in the parent directory of the .gitignore file?

.gitignore 放在父目录中。
.gitignore 可以忽略内部文件夹中的文件,但不能忽略父文件夹中的文件。


.gitignore is collecting information in a commutative way:

  • System level -(全局)例如,如果您是 unix 用户并且您希望要忽略所有项目的所有 *.so 文件,您将把它放在全局文件中

  • Local - 通常会在项目层面申请所有内容给定的项目。

  • Per folder - 给定文件夹的特定定义(例如 - 忽略密码文件,日志文件等或您希望忽略的任何其他资源)

如果您希望忽略父文件夹,请将 .gitignore 也放入此文件夹中。


.gitignore 从最顶层文件夹向下累积所需的模式,它不能 "look" 向上并设置任何指向其父级的模式。