Managing .DS_Store Files in Git: How to Ignore and Remove Them
How to prevent these from appearing…
Step 1: Add .DS_Store to .gitignore
-
Add
.DS_Storeto your.gitignorefile. -
Run:
git add .gitignore git commit -m "Add .DS_Store to .gitignore"
Step 2: Remove Existing .DS_Store Files
-
Run:
find . -name .DS_Store -print0 | xargs -0 git rm --ignore-unmatch --cached -
Commit and push:
git commit -m "Remove all .DS_Store files" git push
Source: https://github.com/desktop/desktop/issues/15644#issuecomment-2042535667