.DS_Store(英文全稱 Desktop Services Store)是一種由蘋果公司的Mac OS X操作系統(tǒng)所創(chuàng)造的隱藏文件,目的在于存貯目錄的自定義屬性,例如文件們的圖標(biāo)位置或者是背景色的選擇。相當(dāng)于 Windows 下的 desktop.ini。刪掉后會(huì)自動(dòng)重新生成。
刪除Git項(xiàng)目中的 .DS_Store
1.打開項(xiàng)目路徑
cd 項(xiàng)目路徑
2.刪除路徑下所有.DS_Store
find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch
3.將 .DS_Store 加入到 .gitignore
echo .DS_Store >> ~/.gitignore
4.更新到Git
git add .
git commit -m '.DS_Store banished!'
git push origin master
刪除、禁止生成
如果你只需要?jiǎng)h除磁盤上的 .DS_Store,可以使用下面的命令來(lái)刪除當(dāng)前目錄及其子目錄下的所有.DS_Store 文件:
1.刪除當(dāng)前目錄的 .DS_store
find . -name '*.DS_Store' -type f -delete
2.刪除所有目錄的 .DS_store
sudo find / -name ".DS_Store" -depth -exec rm {} \;
3.禁止 .DS_store 生成
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE
4.恢復(fù) .DS_store 生成
defaults delete com.apple.desktopservices DSDontWriteNetworkStores