title: Xcode git can't ignore all *.xcodeproj/xcuserdata/ folders
body: <p>I followed <a href="https://stackoverflow.com/questions/6564257/cant-ignore-userinterfacestate-xcuserstate">cant-ignore-userinterfacestate-xcuserstate</a> and <a href="https://stackoverflow.com/questions/1139762/ignore-files-that-have-already-been-committed-to-a-git-repository">ignore-files-that-have-already-been-committed-to-a-git-repository</a>. But these never works.</p>
  
  <p>My Step Reproduction:</p>
  
  <ol>
  <li>Quit Xcode</li>
  <li>project directory: <code>git rm -r --cached .</code></li>
  <li>project directory: <code>git add . &amp;&amp; git commit -m "remove junk files"</code></li>
  <li>Open Xcode project</li>
  <li>Then these files appear again.</li>
  </ol>
  
  <p>Most troubled me was that each time I rebase code will automatic appear these files so I will rebase fail of unstage files. Each time I need to stash these file. </p>
  
  <p>This is my .gitignore file code section:</p>
  
  <pre><code>### Xcode Patch ###
  *.xcodeproj/*
  !*.xcodeproj/project.pbxproj
  !*.xcodeproj/xcshareddata/
  !*.xcworkspace/contents.xcworkspacedata
  /*.gcno
  
  *.xcodeproj/xcuserdata/
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/POBp5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/POBp5.png" alt="source tree want to ignored files"></a></p>
  
  <p><a href="https://i.stack.imgur.com/mngnH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mngnH.png" alt="my xcode project structure"></a></p>
  
  <p><a href="https://i.stack.imgur.com/pvppF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pvppF.png" alt="this is a react-native project"></a></p>