git status 仍然显示 DS_Store 文件,即使它在忽略列表中

标签 git

在 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/

相关文章:

Git 推送导致 fatal error : protocol error: bad line length character: This

Git 从另一个分支中选择更改

git - 通过curl添加SSH key : Fingerprint cannot be generated

git - Git:当我从不同计算机到同一远程分支使用 “push”不同的代码时,会发生什么?

git - 如何获取 Git 中当前提交的哈希值?

git - 查看个别家长的git diff

python - pipenv ssh + git在不可编辑模式下不起作用

git - git-rm --cached 在 pull 时会删除另一个用户的工作树文件吗

git - 堆栈跟踪 :\sshd. exe : *** fatal error - could not load u, Win32 错误 1114,COPSSH GIT TORTOISEGIT

java - 尝试使用 EGit 将 GIT 项目从 IntelliJ IDEA 迁移到 Eclipse?