0

In my repo's .gitignore file, I have :

*.xcuserstate

which means I would like to ignore all files ending with .xcuserstate.

I added that ignore rule long time ago. However, today I still see changes not stated for commit with following file

MyApp/MyApp.xcodeproj/project.xcworkspace/xcuserdata/john.xcuserdatad/UserInterfaceState.xcuserstate

Why? Why .gitignore doesn't work?

Leem.fin
  • 40,781
  • 83
  • 202
  • 354
  • 3
    Was that file already committed at some point? `.gitignore` only affects untracked files. – Ry- Aug 22 '17 at 15:09
  • @Ryan, yes, it has already been committed, what should I do to ignore it now? – Leem.fin Aug 22 '17 at 15:27
  • 1
    You’ll have to make a commit that deletes it, then: `git rm --cached path/to/UserInterfaceState.xcuserstate`. – Ry- Aug 22 '17 at 15:33
  • Possible duplicate of [.gitignore is not working](https://stackoverflow.com/questions/11451535/gitignore-is-not-working) – phd Aug 22 '17 at 19:48

1 Answers1

2

From the gitignore doc

gitignore - Specifies intentionally untracked files to ignore

Which means that .gitignore only affects untracked files.

To ignore an already tracked file refer to Applying .gitignore to committed files

Note that you will have to remove the file from the repository

Community
  • 1
  • 1
Francesco
  • 4,052
  • 2
  • 21
  • 29