forkdog

记录学习的地方

0%

git忽略.DS_Store文件

1. 先删除原有的.DS_Store

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

命令解释:在当前文件夹以及当前文件夹的子文件夹中找到所有的.DS_Store文件,并将找到的文件通过管道传给xargs来处理。注意几个参数的理解:
-print0:在find后不添加换行符(-print默认会添加换行符)
-0:将管道送来的字符串当做普通的字符串,不做任何转义处理。

2. 建立.gitignore文件

vi .gitignore。然后添加.DS_Store作为忽略:shell

1
*/.DS_Store

3. 提交到git

1
2
git add .gitignore
git commit -m 'delete .DS_Store'