无法忽略 UserInterfaceState.xcuserstate
我使用 Git 进行 Xcode 4 项目版本控制。我已将 ProjectFolder.xcodeproj/project.xcworkspace/xcuserdata/myUserName.xcuserdatad/UserInterfaceState.xcuserstate
显式添加到 .gitignore
,但 Git 不会忽略它。有什么想法为什么会这样吗?
I'm using Git for Xcode 4 project version control. I've explicitly added ProjectFolder.xcodeproj/project.xcworkspace/xcuserdata/myUserName.xcuserdatad/UserInterfaceState.xcuserstate
to .gitignore
, but Git it won't ignore it. Any ideas why this is so?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(14)
Git 可能已经在跟踪该文件。
来自 gitignore 文档:
使用此方法,将
[project]
和[username]
替换为您的信息:或者,您可以使用
-a
选项git commit
将添加所有文件已被修改或删除的。从 git 中删除文件后,它将尊重您的
.gitignore
。Git is probably already tracking the file.
From the gitignore docs:
Use this, replacing
[project]
and[username]
with your info:Alternatively you can use the
-a
option togit commit
that will add all files that have been modified or deleted.Once you've removed the file from git, it will respect your
.gitignore
.如果被忽略的文件一直出现在未跟踪列表中,您可以使用 git clean -f -d
把事情弄清楚。
1.
2.
3.
警告首先尝试 git clean -f -d --dry-run ,否则您可能会丢失未提交的更改。
然后:
git clean -f -d
In case that the ignored file kept showing up in the untracked list, you may use
git clean -f -d
to clear things up.
1.
2.
3.
WARNING first try
git clean -f -d --dry-run
, otherwise you may lose uncommited changes.Then:
git clean -f -d
所有答案都很好,但如果您在不同的 Mac(家庭和办公室)中工作,则以下是将为每个用户删除的答案
All Answer is great but here is the one will remove for every user if you work in different Mac (Home and office)
有一位朋友向我展示了这个令人惊叹的网站 https://www.gitignore.io/。输入您选择的 IDE 或其他选项,它将自动生成一个由有用的忽略组成的 gitignore 文件,其中之一是 xcuserstate。您可以在下载之前预览
gitignore
文件。Had a friend show me this amazing site https://www.gitignore.io/. Enter the IDE of your choice or other options and it will automatically generate a
gitignore
file consisting of useful ignores, one of which is thexcuserstate
. You can preview thegitignore
file before downloading.如果执行此处提到的所有操作后文件仍然显示,请确保未选中 Xcode 设置中的此复选框:
In case the file keeps showing up even after doing everything mentioned here, make sure that this checkbox in Xcode settings is unchecked:
只是
“git clean -f -d”
为我工作!
Just
"git clean -f -d"
worked for me!
这里有一些演示和如果您使用 GitHub,则有捷径,基本思想是相同的。
1.像这样打开终端
2.将以下命令粘贴到终端,后跟一个空格,然后像这样粘贴 .xcuserstate 文件的路径
git rm --cached
3.确保您有正确的 git 忽略,然后提交代码:)
Here are some demo & short cuts if you uses GitHub, the basic ideas are the same.
1. Open terminal like this
2. Paste the below command to terminal followed by a space and then paste the path of the .xcuserstate file simply like this
git rm --cached
3. Make sure you have the correct git ignore and then commit the code :)
这对我有用
从终端打开包含项目文件
project.xcworkspace
的文件夹。写入此命令:
git rm --cached *xcuserstate
这将删除该文件。
This works for me
Open the folder which contains the project file
project.xcworkspace
from the terminal.Write this command:
git rm --cached *xcuserstate
This will remove the file.
如果您使用源树应用程序,这是一种更简单的解决方案。
以下是说明:
1.右键单击要添加到 git 忽略列表的文件,然后选择停止跟踪。
Here is one more simple solution if you are using the source tree app.
here are the instructions
1.Right-click on the file which you want to add to the git ignore list and select stop tracking.

对我来说没有任何作用,但这
行添加到你的 gitignore
For me nothing worked, but this
add this line to your gitignore
以下是关于如何从 git 历史记录中递归删除有问题的文件的非常好的解释:http: //help.github.com/remove-sensitive-data/
非常有用,因为否则工具在尝试显示那些本来就不应该检查的大文件上的差异时往往会“挂起” ...
这是您可以做的(简而言之)以获得摆脱最大的东西:
对我来说非常有效:)
Here is a very nice explanation of how to remove the files in question recursively from your git history: http://help.github.com/remove-sensitive-data/
Very useful, because otherwise tools tend to 'hang' while trying to show the diff on those huge files that shouldn't have been checked in the first place...
Here's what you can do (in short) to get rid of the largest stuff:
Worked very nicely for me :)
您还可以忽略 Xcode 首选项本身的文件。
从 https://www.toptal.com/developers/gitignore 生成 gitignore 文件
转到 Xcode ->首选项->源代码控制 -> git->添加列表中的所有忽略项目...即使 UI 并不是真正有用 &您必须单独添加所有项目,但在此处添加忽略文件肯定有效。
You can also ignore files from Xcode preferences itself.
Generate gitignore file from https://www.toptal.com/developers/gitignore
Go to Xcode -> Preferences -> Source Control -> Git -> Add all ignore items in the list...Even though UI is not really useful & you have to add all items individually but adding ignore files here surely works.
对于 xcode 8.3.3,我刚刚检查尝试了上面的代码并观察到,现在在这种情况下,我们必须将命令更改为这样,
首先您可以使用创建一个 .gitignore 文件,
然后您可以使用此删除所有 userInterface 文件命令,通过使用此命令,它将尊重您的 .gitignore 文件。
For xcode 8.3.3 I just checked tried the above code and observe that, now in this casewe have to change the commands to like this
first you can create a .gitignore file by using
after that you can delete all the userInterface file by using this command and by using this command it will respect your .gitignore file.
我觉得这样写会比较好。
git rm --cache *//UserInterfaceState.xcuserstate**
I think it would be better to write like this.
git rm --cache *//UserInterfaceState.xcuserstate**