无法忽略 UserInterfaceState.xcuserstate

发布于 2024-11-18 04:28:40 字数 214 浏览 5 评论 0原文

我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(14

琴流音 2024-11-25 04:28:40

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 commit 将添加所有文件已被修改或删除的。

从 git 中删除文件后,它将尊重您的 .gitignore

Git is probably already tracking the file.

From the gitignore docs:

To stop tracking a file that is currently tracked, use git rm --cached.

Use this, replacing [project] and [username] with your info:

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

Alternatively you can use the -a option to git 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.

债姬 2024-11-25 04:28:40

如果被忽略的文件一直出现在未跟踪列表中,您可以使用 git clean -f -d
把事情弄清楚。

1.

git rm --cached {YourProjectFolderName}.xcodeproj/project.xcworkspace/xcuserdata/{yourUserName}.xcuserdatad/UserInterfaceState.xcuserstate

2.

git commit -m "Removed file that shouldn't be tracked"

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.

git rm --cached {YourProjectFolderName}.xcodeproj/project.xcworkspace/xcuserdata/{yourUserName}.xcuserdatad/UserInterfaceState.xcuserstate

2.

git commit -m "Removed file that shouldn't be tracked"

3.
WARNING first try git clean -f -d --dry-run, otherwise you may lose uncommited changes.

Then:
git clean -f -d

一场春暖 2024-11-25 04:28:40

所有答案都很好,但如果您在不同的 Mac(家庭和办公室)中工作,则以下是将为每个用户删除的答案

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

All Answer is great but here is the one will remove for every user if you work in different Mac (Home and office)

git rm --cache */UserInterfaceState.xcuserstate
git commit -m "Never see you again, UserInterfaceState"
甜妞爱困 2024-11-25 04:28:40

有一位朋友向我展示了这个令人惊叹的网站 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 the xcuserstate. You can preview the gitignore file before downloading.

⊕婉儿 2024-11-25 04:28:40

如果执行此处提到的所有操作后文件仍然显示,请确保未选中 Xcode 设置中的此复选框:

在此处输入图像描述

In case the file keeps showing up even after doing everything mentioned here, make sure that this checkbox in Xcode settings is unchecked:

enter image description here

呆橘 2024-11-25 04:28:40

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

Just
"git clean -f -d"
worked for me!

茶底世界 2024-11-25 04:28:40

这里有一些演示和如果您使用 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

enter image description here

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
enter image description here

3. Make sure you have the correct git ignore and then commit the code :)

enter image description here

倦话 2024-11-25 04:28:40

这对我有用

  1. 从终端打开包含项目文件project.xcworkspace的文件夹。

  2. 写入此命令:git rm --cached *xcuserstate

这将删除该文件。

This works for me

  1. Open the folder which contains the project file project.xcworkspace from the terminal.

  2. Write this command: git rm --cached *xcuserstate

This will remove the file.

薔薇婲 2024-11-25 04:28:40

如果您使用源树应用程序,这是一种更简单的解决方案。
以下是说明:

1.右键单击要添加到 git 忽略列表的文件,然后选择停止跟踪。

  1. ,您会注意到忽略选项现已启用,然后单击忽略按钮。

输入图像描述这里

  1. 现在您可以重置或提交对同一文件的更改,这取决于您的更改是否重要。将不会跟踪所选文件将来的更改。

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.
enter image description here

  1. again right-click on the same file and you will notice ignore option is now enabled then click on ignore button.

enter image description here

  1. now you can reset or commit your changes for the same file it depends on whether your changes are important or not. changes in the future will not be tracked for the selected file.
古镇旧梦 2024-11-25 04:28:40

对我来说没有任何作用,但这

行添加到你的 gitignore

*.xcuserdata

For me nothing worked, but this

add this line to your gitignore

*.xcuserdata
时光病人 2024-11-25 04:28:40

以下是关于如何从 git 历史记录中递归删除有问题的文件的非常好的解释:http: //help.github.com/remove-sensitive-data/

非常有用,因为否则工具在尝试显示那些本来就不应该检查的大文件上的差异时往往会“挂起” ...

这是您可以做的(简而言之)以获得摆脱最大的东西:

cd YourProject
git filter-branch --index-filter 'git rm --cached --ignore-unmatch -r YourProject.xcodeproj/project.xcworkspace' HEAD
# see what you want to do with your remote here...
# you can: git push origin master --force
# or you can delete it and push a fresh new one from your cleaned-up local...
rm -rf .git/refs/original
git gc --prune=now
git gc --aggressive --prune=now

对我来说非常有效:)

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:

cd YourProject
git filter-branch --index-filter 'git rm --cached --ignore-unmatch -r YourProject.xcodeproj/project.xcworkspace' HEAD
# see what you want to do with your remote here...
# you can: git push origin master --force
# or you can delete it and push a fresh new one from your cleaned-up local...
rm -rf .git/refs/original
git gc --prune=now
git gc --aggressive --prune=now

Worked very nicely for me :)

偏爱自由 2024-11-25 04:28:40

您还可以忽略 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.

enter image description here

enter image description here

enter image description here

煮酒 2024-11-25 04:28:40

对于 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"

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

 touch .gitignore

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 --cached [project].xcworkspace/xcuserdata/[username].xcuserdatad/UserInterfaceState.xcuserstate
 git commit -m "Removed file that shouldn't be tracked"
守望孤独 2024-11-25 04:28:40

我觉得这样写会比较好。

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

I think it would be better to write like this.

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文