我使用Git进行Xcode 4项目版本控制。我明确地添加了ProjectFolder.xcodeproj/project.xcworkspace/xcuserdata/myUserName.xcuserdatad/UserInterfaceState。xcuserstate到.gitignore,但是Git不会忽略它。有人知道为什么吗?


当前回答

你也可以忽略Xcode首选项本身的文件。

从https://www.toptal.com/developers/gitignore生成gitignore文件

去Xcode ->首选项->源控制-> Git ->添加列表中所有忽略项…尽管UI并不是真的有用&你必须单独添加所有项目,但在这里添加忽略文件肯定有效。

其他回答

只是 "git clean -f -d" 为我工作!

所有答案都很棒,但如果你在不同的Mac(家庭和办公室)上工作,这里有一个会为每个用户删除的答案

git rm --cache */UserInterfaceState.xcuserstate
git commit -m "Never see you again, UserInterfaceState"

对于xcode 8.3.3,我刚刚检查了上面的代码,并观察到,现在在这种情况下,我们必须将命令更改为这样

首先,您可以使用。gitignore文件

 touch .gitignore

之后,你可以使用这个命令删除所有的userInterface文件,通过使用这个命令,它将尊重你的.gitignore文件。

 git rm --cached [project].xcworkspace/xcuserdata/[username].xcuserdatad/UserInterfaceState.xcuserstate
 git commit -m "Removed file that shouldn't be tracked"

我觉得这样写比较好。

git rm——cache *//UserInterfaceState.xcuserstate**

对我来说什么都没用,除了这个

把这条线加到你的gitignore里

*.xcuserdata