1. 先刪除原有的.DS_Store:
find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch
命令解釋:在當(dāng)前文件夾以及當(dāng)前文件夾的子文件夾中找到所有的.DS_Store文件劲蜻,并將找到的文件通過管道傳給xargs來處理拘领。注意幾個參數(shù)的理解:
-print0:在find后不添加換行符(-print默認(rèn)會添加換行符)
-0:將管道送來的字符串當(dāng)做普通的字符串俱两,不做任何轉(zhuǎn)義處理。
2. 建立.gitignore文件
vi .gitignore
然后添加.DS_Store作為忽略:
.DS_Store
3. 提交到git
git add .gitignore
git commit -m 'delete .DS_Store'