xcode 不能忽略 UserInterfaceState.xcuserstate

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6564257/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:00:29  来源:igfitidea点击:

Can't ignore UserInterfaceState.xcuserstate

xcodegitxcode4gitignore

提问by GarlicFries

I'm using Git for Xcode 4 project version control. I've explicitly added ProjectFolder.xcodeproj/project.xcworkspace/xcuserdata/myUserName.xcuserdatad/UserInterfaceState.xcuserstateto .gitignore, but Git it won't ignore it. Any ideas why this is so?

我正在使用 Git 进行 Xcode 4 项目版本控制。我已经明确添加ProjectFolder.xcodeproj/project.xcworkspace/xcuserdata/myUserName.xcuserdatad/UserInterfaceState.xcuserstate.gitignore,但 Git 不会忽略它。任何想法为什么会这样?

回答by matt

Git is probably already tracking the file.

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

From the gitignore docs:

gitignore 文档

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

要停止跟踪当前跟踪的文件,请使用git rm --cached

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

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

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 -aoption to git committhat will add all files that have been modified or deleted.

或者,您可以使用该-a选项git commit添加所有已修改或删除的文件。

Once you've removed the file from git, it will respect your .gitignore.

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

回答by Xing

In case that the ignored file kept showing up in the untracked list, you may use git clean -f -dto clear things up.

如果被忽略的文件一直显示在未跟踪列表中,您可以使用git clean -f -d来清除它。

1.

1.

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

2.

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.

3. 警告先尝试git clean -f -d --dry-run,否则可能会丢失未提交的更改。

Then: git clean -f -d

然后: git clean -f -d

回答by hardikdevios

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

All Answer 很棒,但如果您在不同的 Mac(家庭和办公室)上工作,这里将为每个用户删除一个

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

回答by Josh Valdivieso

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 gitignorefile consisting of useful ignores, one of which is the xcuserstate. You can preview the gitignorefile before downloading.

让一位朋友向我展示了这个神奇的网站https://www.gitignore.io/。输入您选择的 IDE 或其他选项,它将自动生成一个gitignore包含有用忽略的文件,其中之一是xcuserstate. 您可以gitignore在下载前预览文件。

回答by Lukas Kalinski

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

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

enter image description here

在此处输入图片说明

回答by rilar

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

只是“git clean -f -d”对我有用!

回答by Fangming

Here are some demo & short cuts if you uses GitHub, the basic ideas are the same.

如果你使用 GitHub,这里有一些演示和捷径,基本思路是一样的。

1. Open terminal like this

1. 像这样打开终端

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

2. 将下面的命令粘贴到终端,后跟一个空格,然后像这样粘贴 .xcuserstate 文件的路径

git rm --cachedenter image description here

git rm --cached在此处输入图片说明

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

3. 确保你有正确的 git ignore 然后提交代码:)

enter image description here

在此处输入图片说明

回答by Zoran Simic

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/

这是如何从您的 git 历史记录中递归删除有问题的文件的一个很好的解释: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 :)

对我来说非常好:)

回答by Qadir Hussain

For me nothing worked, but this

对我来说没有任何效果,但这

add this line to your gitignore

将此行添加到您的 gitignore

*.xcuserdata

回答by Mohammed Ali Khaled

This works for me

这对我有用

  1. Open the folder which contains the project file project.xcworkspacefrom the terminal.

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

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

  2. 写这个命令: git rm --cached *xcuserstate

This will remove the file.

这将删除文件。