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


当前回答

我觉得这样写比较好。

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

其他回答

Git可能已经在跟踪该文件。

gitignore文件中写道:

要停止跟踪当前正在跟踪的文件,请使用git rm——cached。

使用这个,用你的信息替换[project]和[username]:

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

或者你也可以使用-a选项来提交git,这将添加所有被修改或删除的文件。

一旦你从git中删除了这个文件,它就会尊重你的.gitignore。

我觉得这样写比较好。

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

有个朋友给我看了这个很棒的网站https://www.gitignore.io/。输入您选择的IDE或其他选项,它将自动生成一个由有用的忽略组成的gitignore文件,其中之一是xcuserstate。您可以在下载之前预览gitignore文件。

这对我很有用

打开包含项目文件project的文件夹。Xcworkspace。 这样写:git rm——cached *xcuserstate

这将删除文件。

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

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