Time: 2021-03-31 08:43 UTC+8:00
Author: vonhyou
.DS_Store
is a file that stores custom attributes of its folder (like icons). .DS_Store
is a abbr. of Desktop Service Store . This file is similar to the desktop.ini
in Windows OS. So that, it's not necessay to add this file into a git repo. Let me tell you how to remove it by adding .gitignore
rules.
- If you had already add
.DS_Store
files into a git repo, you have to delete it using command below:
$ find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch
- Append a rule to
.gitignore
file
$ echo .DS_Store >> .gitignore
- Update repo
$ git commit -am "remove .DS_Store files"
If you don't want to repeat it, it's possible to set this rule globally.
- Creat a new file called
.gitignore_global
(or any other you like )
$ touch ~/.gitignore_global
- Assign this file as a global rule set
$ git config --global core.excludesfile ~/.gitignore_global
- Add the rule to
.gitignore_global
$ echo .DS_Store >> ~/.gitignore_global
Done.
Top comments (2)
Thanks for sharing.
Thank you for this. I've done it but .DS_Store is still in my repo. I wonder if there's anything I'm missing?