Git忽略.DS_Store文件

.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
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容