.DS_Store 是什么
使用 Mac 的用戶可能會注意到整吆,系統(tǒng)經(jīng)常會自動在每個目錄生成一個隱藏的 .DS_Store 文件。.DS_Store(英文全稱 Desktop Services Store)是一種由蘋果公司的Mac OS X操作系統(tǒng)所創(chuàng)造的隱藏文件,目的在于存貯目錄的自定義屬性剧浸,例如文件們的圖標位置或者是背景色的選擇画机。相當于 Windows 下的 desktop.ini。
刪除 .DS_Store
如果你的項目中還沒有自動生成的 .DS_Store 文件系任,那么直接將 .DS_Store 加入到 .gitignore 文件就可以了恳蹲。如果你的項目中已經(jīng)存在 .DS_Store 文件,那就需要先從項目中將其刪除俩滥,再將它加入到 .gitignore嘉蕾。如下:
刪除項目中的所有.DS_Store。這會跳過不在項目中的 .DS_Store
1.find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch
將 .DS_Store 加入到 .gitignore
2.echo .DS_Store >> ~/.gitignore
更新項目
3.git add --all
4.git commit -m '.DS_Store banished!'
如果你只需要刪除磁盤上的 .DS_Store霜旧,可以使用下面的命令來刪除當前目錄及其子目錄下的所有.DS_Store 文件:
find . -name '*.DS_Store' -type f -delete
禁用或啟用自動生成
禁止.DS_store生成:
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE
恢復.DS_store生成:恢復.DS_store生成:
defaults delete com.apple.desktopservices DSDontWriteNetworkStores