5

I am new to Git, and every time I work with it, I always get this annoying .DS_Store in my untracked files. I am assuming that is where my working directory is.

I have tried searching the answer on Stack Overflow, but only found the answer on how to remove it from the repository, not from the list of untracked files.

How can I tell Git to completely ignore .DS_Store files and never list them as untracked files?

Mureinik
  • 297,002
  • 52
  • 306
  • 350
Eldan Shkolnikov
  • 441
  • 1
  • 6
  • 13
  • 3
    Have you tried adding ".DS_Store" in your .gitignore file? – Pan Long Dec 05 '14 at 14:25
  • 1
    Adding a `.DS_Store` entry in the project's `.gitignore` file works, but you're better off using a *global* `.gitignore` file for ignoring such OS-dependent files. See http://stackoverflow.com/a/26851996/2541573 – jub0bs Dec 05 '14 at 14:34

1 Answers1

15

You could create a .gitignore file. This file tells git which file (changes) it should ignore, so they won't appear in git status, git diff etc. call.

.gitignore is a simple text file. Just create it in a text editor (or edit it if you already have one), and add this line:

.DS_Store

Then, you should add it to the repository, so these files are ignored by all collaborators:

git add .gitignore
git commit -m "added .gitignore"
Mureinik
  • 297,002
  • 52
  • 306
  • 350