我不希望我的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")
您的.DS_Store
在添加到.gitignore
之前就已提交。您可以使用以下命令将其从存储库中删除:
git rm --cached .DS_Store
git commit -m '.DS_Store untracked'
--cached
选项将仅从索引中删除文件,但不会删除文件本身。
完成此操作后,Git 将不再跟踪该文件,并且将被正确忽略。
您之前可能已提交此文件。尝试此操作以将其删除:
git rm --cached .DS_Store