在 git 忽略列表中我有:
build/**
.DS_Store
更新一些文件后 git status 显示:
modified: db/main/res/.DS_Store
我没想到会显示.DS_Store
被修改了,因为它在忽略列表中。工作目录或项目根目录是 ~/myproj
。
如何解决这个问题?
最佳答案
当您运行 git add
时,.gitignore 文件中的“.DS_Store”条目将阻止 Git 跟踪新的 .DS_Store 文件。
听起来您的问题是在将 .DS_Store 包含在 .gitignore 文件中之前,Git 正在跟踪 .DS_Store 文件。
因此,您需要做的就是使用 git rm --cached db/main/res/.DS_Store
从存储库中删除 .DS_Store 文件,此后将不会对其进行跟踪。
(在 Edward 的评论后添加 --cached)。
关于git status 仍然显示 DS_Store 文件,即使它在忽略列表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34846807/