DS_Store 是给Finder用来存储这个文件夹的显示属性的:比如文件图标的摆放位置。删除以后的副作用就是这些信息的失去。(当然,这点副作用其实不是太大).
1、删除所有已有的 .DS_store文件,以下几个命令均可
find . -name '*.DS_Store' -type f -delete # 删除当前目录下的 .DS_store
find / -name '*.DS_Store' -type f -delete # 删除磁盘上所有的 .DS_store
删除项目中的所有.DS_Store。这会跳过不在项目中的 .DS_Store (未测试)
find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch
2、将 .DS_Store 加入到 .gitignore
在git中如果想忽略掉某个文件,不让这个文件提交到版本库中,可以使用修改根目录中 .gitignore 文件的方法(如无,则需自己手工建立此文件)。这个文件每一行保存了一个匹配的规则例如:
# 此为注释 – 将被 Git 忽略
*.a # 忽略所有 .a 结尾的文件
!lib.a # 但 lib.a 除外
/TODO # 仅仅忽略项目根目录下的 TODO 文件,不包括 subdir/TODO
build/ # 忽略 build/ 目录下的所有文件
doc/*.txt # 会忽略 doc/notes.txt 但不包括 doc/server/arch.txt
加入方法为:
echo .DS_Store >> ~/.gitignore
3、禁止.DS_store生成:
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE
4、恢复.DS_store生成:
defaults delete com.apple.desktopservices DSDontWriteNetworkStores