Search code examples
gitgithubgitignore

git ignore file ending with certain suffix doesn't work


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?


Solution

  • 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