2

I followed cant-ignore-userinterfacestate-xcuserstate and ignore-files-that-have-already-been-committed-to-a-git-repository. But these never works.

My Step Reproduction:

  1. Quit Xcode
  2. project directory: git rm -r --cached .
  3. project directory: git add . && git commit -m "remove junk files"
  4. Open Xcode project
  5. Then these files appear again.

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.

This is my .gitignore file code section:

### Xcode Patch ###
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata/
!*.xcworkspace/contents.xcworkspacedata
/*.gcno

*.xcodeproj/xcuserdata/

source tree want to ignored files

my xcode project structure

this is a react-native project

FaiChou
  • 767
  • 7
  • 16
  • Please see _comments_ on this answer: https://stackoverflow.com/a/6565909/5306470 . Also, see: https://stackoverflow.com/questions/31437170/what-should-i-include-in-the-gitignore-file-for-swift-playgrounds –  May 10 '18 at 03:11

1 Answers1

3

I just realized that these want to ignored files was buried in deep folder.

And git don't support this kind of pattern *.xcodeproj/xcuserdata/.

Want to ignore other son son (recursive) folder need add this to .gitignore:

ios/**/*.xcodeproj/xcuserdata/

or a clean way:

**/xcuserdata/

This **/*.xcodeproj was git version 1.8.2's feature.

$ git --version
git version 2.16.1

So most of us can use it.

I learnt from how-to-gitignore-files-recursively.

FaiChou
  • 767
  • 7
  • 16