1. 程式人生 > >如何刪除mac中的.DS_Store和git中的.DS_Store

如何刪除mac中的.DS_Store和git中的.DS_Store

.DS_Store 是什麼 使用 Mac 的使用者可能會注意到,系統經常會自動在每個目錄生成一個隱藏的 .DS_Store 檔案。.DS_Store(英文全稱 Desktop Services Store)是一種由蘋果公司的Mac OS X作業系統所創造的隱藏檔案,目的在於存貯目錄的自定義屬性,例如檔案們的圖示位置或者是背景色的選擇。相當於 Windows 下的 desktop.ini。

Git中多了.DS_Store檔案怎麼辦!?

1.如果還在你本地分支上的話,就直接在mac系統上刪除了這些檔案重新push一下 開啟命令列視窗: 刪除當前目錄及其子目錄下的所有.DS_Store 檔案

find . -name '*.DS_Store' -type f -delete 1 刪除所有隱藏.DS_store檔案(可以不要執行這步)

sudo find / -name ".DS_Store" -depth -exec rm {} \;  1 2.如果你的專案中還沒有自動生成的 .DS_Store 檔案,那麼直接將 .DS_Store 加入到 .gitignore 檔案就可以了。如果你的專案中已經存在 .DS_Store 檔案,那就需要先從專案中將其刪除,再將它加入到 .gitignore(什麼是.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!' 1 2 3 4 5 6 7 禁止.DS_store生成: defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE 1 恢復.DS_store生成:恢復.DS_store生成: defaults delete com.apple.desktopservices DSDontWriteNetworkStores ---------------------  作者:不虧  來源:CSDN  原文:https://blog.csdn.net/a419419/article/details/80801243  版權宣告:本文為博主原創文章,轉載請附上博文連結!