Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Removes .DS_Store (Mac files) from a Git repo
#!/usr/bin/env bash
# .DS_Store files on Mac are meta files that tell Finder the window position and size of a previously opened folder.
# They are harmless but add clutter and useless code to your repos. This script removes them from your repo but not
# from your local file system.
# Remove .DS_Store from git
find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch
# Add .DS_Store files to gitignore
echo .DS_Store >> .gitignore
# Commit to your repo
git add .gitignore
git commit -m '.DS_Store banished!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment