提交时未知文件名出现在层次结构中

Unknown filename appears on hierarchical while commiting

我不明白有一个文件不在 git 存储库中,也不在本地存储库中(甚至不在本地和物理文件夹中),但是当我要提交或推送时,它在文件中似乎是分层的?通过取消选中此文件,我可以正确地推送和拉取代码,但我很想知道确切的问题是什么。

.DS_Store 是一个隐藏文件,由 MacOS 创建,用于存储有关包含文件夹的信息。您应该将此文件添加到您的 .gitignore,这样 git 将永远不会在您的 untracked/modified 列表中显示它。

根据wikipedia

In the Apple macOS operating system, .DS_Store is a file that stores custom attributes of its containing folder, such as the position of icons or the choice of a background image. The name is an abbreviation of Desktop Services Store, reflecting its purpose. It is created and maintained by the Finder application in every folder

.DS_Store 是将出现在默认 HFS+ 文件系统的每个目录中的 MacOS 系统文件。您的 Finder 很可能不会显示隐藏文件(带点前缀)。你可以设置 .gitignore 不包含 .DS_Store, details here

您似乎已将文件名 EditOrNewAddressVuewController.m 更改为 EditOrNewAddressVuewController~.m,将此信息保存在 .DS_Store 中,然后您将代码推送到远程,因为 .DS_Store信息有未跟踪的文件出现在你身上 Git 工作树层次结构,

如果您不喜欢这个未跟踪的文件,请删除 .DS_Store 添加 .gitignore 文件。有帮助 link1, link2,link3

即使,有一种愚蠢的方法可以避免观看此内容,将项目克隆到另一个文件夹中;)