如何删除GIT中的.DS_Store
DS_Store 是什么
使用 Mac 的用戶(hù)可能會(huì)注意到,系統(tǒng)經(jīng)常會(huì)自動(dòng)在每個(gè)目錄生成一個(gè)隱藏的 .DS_Store 文件。.DS_Store(英文全稱(chēng) Desktop Services Store)是一種由蘋(píng)果公司的Mac OS X操作系統(tǒng)所創(chuàng)造的隱藏文件,目的在于存貯目錄的自定義屬性,例如文件們的圖標(biāo)位置或者是背景色的選擇。相當(dāng)于 Windows 下的 desktop.ini。
刪除 .DS_Store
如果你的項(xiàng)目中還沒(méi)有自動(dòng)生成的 .DS_Store 文件,那么直接將 .DS_Store 加入到 .gitignore 文件就可以了。如果你的項(xiàng)目中已經(jīng)存在 .DS_Store 文件,那就需要先從項(xiàng)目中將其刪除,再將它加入到 .gitignore。如下:
刪除項(xiàng)目中的所有.DS_Store。這會(huì)跳過(guò)不在項(xiàng)目中的 .DS_Store
find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch將 .DS_Store 加入到 .gitignore
echo .DS_Store >> ~/.gitignore更新項(xiàng)目
git add --all git commit -m '.DS_Store banished!'如果你只需要?jiǎng)h除磁盤(pán)上的 .DS_Store,可以使用下面的命令來(lái)刪除當(dāng)前目錄及其子目錄下的所有.DS_Store 文件:
find . -name '*.DS_Store' -type f -delete禁用或啟用自動(dòng)生成
禁止.DS_store生成:
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE恢復(fù).DS_store生成:恢復(fù).DS_store生成:
defaults delete com.apple.desktopservices DSDontWriteNetworkStores20200420更新
終端刪除文件:
sudo find / -name ".DS_Store" -depth -exec rm {} ;防止再生成文件
按下回車(chē)鍵盤(pán)之后,終端會(huì)提示用戶(hù)名和密碼,直接輸入密碼再按回車(chē)即可。
刪除后繼續(xù)在終端輸入:
defaults write com.apple.desktopservices DSDontWriteNetworkStores true總結(jié)
以上是生活随笔為你收集整理的如何删除GIT中的.DS_Store的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 转载:越早明白这四个道理越好!
- 下一篇: 文章章节序号编排常识