如何从Git存储库中删除那些烦人的Mac OS X.DS_Store文件?


当前回答

如果您无法删除这些文件,因为它们有暂存的更改,请使用:

git rm --cached -f *.DS_Store

其他回答

使用此命令删除现有文件:

find . -name '*.DS_Store' -type f -delete

然后将.DS_Store添加到.gitignore

$ git commit -m "filter-branch --index-filter 'git rm --cached --ignore-unmatch .DS_Store"
$ git push origin master --force

这对我很有用,上面有两个答案:

$git rm--缓存-f*.DS_Store$gitcommit-m“过滤器分支--索引过滤器'git rm--缓存--忽略取消匹配.DS_Store“$git推送原始主机--强制

删除忽略的文件:

(.DS_Store)

$ find . -name .DS_Store -print0 | xargs -0 git rm --ignore-unmatch

这将起作用:

find . -name "*.DS_Store" -type f -exec git-rm {} \;

它将删除所有名称以.DS_Store结尾的文件,包括._。DS_存储。