macOS 系統 .DS_Store 文件詳解


.DS_Store 文件

.DS_Store 是 Finder 用來存儲這個文件夾的顯示屬性的:比如文件圖標的擺放位置。

顯示/隱藏 Mac 隱藏文件

  • 顯示defaults write com.apple.finder AppleShowAllFiles -bool true
  • 隱藏defaults write com.apple.finder AppleShowAllFiles -bool false

刪除 .DS_Store 文件

  • find /path/to/files -name ".DS_Store" -delete
  • find /path/to/files –type f –name ".DS_Store" -print –delete
  • find /path/to/files –type f –name ".DS_Store" -print0 | xargs –0 rm -rdf

配置 SVN 忽略 .DS_Store 文件

  1. 編輯~/.subversion/config文件;

  2. 找到global-ignores配置項,取消注釋;

  3. 添加上自己要忽略的文件,用空格隔開

    global-ignores = *.iml .idea .DS_Store .sass-cache node_modules *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo
    

這是針對客戶端的全局修改,不會對 SVN 服務端有影響,忽略的文件列表不會再出現在 SVN 的操作中。

防止 .DS_Store 文件生成

defaults write com.apple.desktopservices DSDontWriteNetworkStorestrue true

配置 Git 忽略 .DS_Store 文件

  • .gitignore 配置文件用於配置不需要加入版本管理的文件
  • 語法
    • 以斜杠"/"開頭表示目錄;
    • 以星號"*"通配多個字符;
    • 以問號"?"通配單個字符
    • 以方括號"[]"包含單個字符的匹配列表;
    • 以嘆號"!"表示不忽略(跟蹤)匹配到的文件或目錄;
  • Git 對於 .gitignore 配置文件是按行從上到下進行規則匹配的,意味着如果前面的規則匹配的范圍更大,則后面的規則將不會生效。
  1. 對該 repo 的所有用戶應用過濾
    .gitignore 文件放在工作目錄的跟目錄,編輯 .gitignore 完成后提交 git add .gitignore

  2. 僅對自己的 repo 備份過濾
    添加/編輯你工作目錄的$GIT_DIR/info/exclude,例如你的working copy目錄是~/src/project1,則路徑為~/src/project1/.git/info/exclude

  3. 系統全局過濾
    創建一個 ignore 文件,名字隨意起,比如我的放在~/.gitglobalignore,然后配置 git:

    git config —global core.excludesfile = ~/.gitglobalignore
    
  • 忽略 .DS_Store
    添加 .DS_Store.gitignore 文件即可

原文地址: https://shockerli.net/post/macos-ds_store/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM