Skip to content

Instantly share code, notes, and snippets.

@iconifyit
Created September 24, 2020 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iconifyit/4ae3f9f2a37ac0d8db480e5a042038eb to your computer and use it in GitHub Desktop.
Save iconifyit/4ae3f9f2a37ac0d8db480e5a042038eb to your computer and use it in GitHub Desktop.
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