首页 > 解决方案 > Git 忽略 .gitignore 文件并说 .DS_Store 文件已修改

问题描述

我不希望我的 MacBook 的 .DS_Store 文件被提交到我的 Git 存储库。

不幸的是,我的 .gitignore 甚至 .gitignore_global 似乎都被完全忽略了。

任何想法可能是什么原因?

 ujjain:~/Dropbox/workspace| (HEAD) [+1] | feature/Jenkinsfile [+1]
$ cat .gitignore
...

# Mac OS Test
.DS_Store
 ujjain:~/Dropbox/workspace| (HEAD) [+1] | feature/Jenkinsfile [+1]
$ git status
On branch feature/Jenkinsfile
Your branch is up to date with 'origin/feature/Jenkinsfile'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

  modified:   .DS_Store

no changes added to commit (use "git add" and/or "git commit -a")

标签: gitgitignore

解决方案


您之前可能已经提交过此文件。试试这个来删除它:

git rm --cached .DS_Store

推荐阅读