删除GIT中的.DS_Store

 
.DS_Store 是什么

使用 Mac 的用户可能会注意到,系统常常会自动在每一个目录生成一个隐藏的 .DS_Store 文件。.DS_Store(英文全称 Desktop Services Store)是一种由苹果公司的Mac OS X操做系统所创造的隐藏文件,目的在于存贮目录的自定义属性,例如文件们的图标位置或者是背景色的选择。至关于 Windows 下的 desktop.ini。git

删除 .DS_Store

若是你的项目中尚未自动生成的 .DS_Store 文件,那么直接将 .DS_Store 加 入到 .gitignore 文件就能够了。 若是你的项目中已经存在 .DS_Store 文件,那就须要先从项目中将其删除,再将它加入到 .gitignore。以下:app

删除项目中的全部.DS_Store。这会跳过不在项目中的 .DS_Store

  1. find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch

将 .DS_Store 加入到 .gitignore

  1. echo .DS_Store >> ~/.gitignore

更新项目

  1. git add --all
  2. git commit -m '.DS_Store banished!'

若是你只须要删除磁盘上的 .DS_Store,能够使用下面的命令来删除当前目录及其子目录下的全部.DS_Store 文件ide

find . -name '*.DS_Store' -type f -delete操作系统

禁用或启用自动生成
  1. 禁止.DS_store生成:

defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUEit

  1. 恢复.DS_store生成:恢复.DS_store生成:

defaults delete com.apple.desktopservices DSDontWriteNetworkStoresclass

相关文章
相关标签/搜索