27

In this case I want to ignore the files iOS uses, and in particular this file

.DS_Store

I created a .gitignore file as such

touch .gitignore

and put in a single line

/.DS_Store

I push to a bare repo which has a hook to checkout to a full repo.

The file keeps showing up in my full repo.

cade galt
  • 3,315
  • 6
  • 28
  • 44
  • 4
    The correct entry would be just ".DS_Store". It will also still appear if it is already in your repository. – doublesharp Aug 15 '15 at 14:52
  • 2
    have you tried to remove the `cached` copy of a file `git rm --cached path_to_file`? – Philidor Aug 15 '15 at 14:55
  • That *is* what it is. Like I mentioned in my first comment, if it's already in the repository it will show up even if it is in `.gitignore`. – doublesharp Aug 15 '15 at 15:33

2 Answers2

36

You can also remove committed .DS_Store files like this: git rm --cached .DS_Store

CroMagnon
  • 1,206
  • 7
  • 20
  • 32
wasddd_
  • 648
  • 1
  • 9
  • 17
30

As you mentioned in your comment, you've already committed the .DS_Store file. To fix this, just remove the file and make a commit. Then, as long as you have your .gitignore file set up and stored in your repo, you shouldn't see any more problems with .DS_Store files.

taylorc93
  • 3,566
  • 2
  • 19
  • 34