本文最后更新于 2020年08月13日
)
如果你的项目中还没有自动生成的 .DS_Store 文件,那么直接将 .DS_Store 加入到 .gitignore 文件就可以了。如果你的项目中已经存在 .DS_Store 文件,那就需要先从项目中将其删除,再将它加入到 .gitignore。如下:
1 2 3 4 5 6 7 8 | # 删除项目中的所有.DS_Store。这会跳过不在项目中的 .DS_Store# cd 你的项目目录find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch# 将 .DS_Store 加入到 .gitignoreecho .DS_Store >> ~/.gitignore# 更新项目git add --allgit commit -m '.DS_Store banished!' |
全局忽略.DS_Store
1 2 | git config --global core.excludesfile ~/.gitignoreecho .DS_Store >> ~/.gitignore |