xcode xcuserdata 文件夹中所有内容的 .gitignore 不会忽略 xcuserstate 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15646107/
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:46:29  来源:igfitidea点击:

.gitignore for everything inside the xcuserdata folder does not ignore an xcuserstate file

xcodegitgitignore

提问by Fernando

I'm working in a Xcode project, and I'm trying to configure the .gitignore to not get anything inside the xcuserdata folder.

我正在一个 Xcode 项目中工作,我正在尝试配置 .gitignore 以不在 xcuserdata 文件夹中获取任何内容。

I have the following .gitignore:

我有以下.gitignore:

# Xcode
.DS_Store
*/build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
*.hmap
xcuserdata/*

but every time that I build/run the project and execute git status, it still shows the following midified file:

但是每次我构建/运行项目并执行时git status,它仍然显示以下中间文件:

modified: MyProject.xcodeproj/project.xcworkspace/xcuserdata/fernando.xcuserdatad/UserInterfaceState.xcuserstate

Does anybody have any idea what's wrong?

有人知道出了什么问题吗?

回答by Fernando

I found the solution

我找到了解决方案

the problem was not in the .gitignore file

问题不在 .gitignore 文件中

the problem was the UserInterfaceState.xcuserstate that was not removed from git server, found the solution in the following link:

问题是没有从 git 服务器中删除的 UserInterfaceState.xcuserstate,在以下链接中找到了解决方案:

Can't ignore UserInterfaceState.xcuserstate

不能忽略 UserInterfaceState.xcuserstate

回答by nferocious76

Additional info

附加信息

I have also encountered this and seems not to work since .gitignore still adding them after committing. What I have added does the charm for me

我也遇到过这种情况并且似乎不起作用,因为 .gitignore 在提交后仍然添加它们。我添加的东西对我来说很有吸引力

.... this can't be read by the .gitignore:

.... 这不能被 .gitignore 读取:

xcuserdata/*

adding this works for me:

添加这对我有用:

*xcworkspace/xcuserdata/*

or to be read:

或阅读:

*/xcuserdata/*

回答by Qadir Hussain

For me nothing worked, but this

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

add this line to your gitignore

将此行添加到您的 gitignore

*.xcuserdata

回答by Giang

If you used git, you can add .gitignore

如果你用过 git,你可以添加 .gitignore

# Xcode
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
*.moved-aside
DerivedData
.idea/
*.xccheckout
*.moved-aside
xcuserdata/
*.hmap
*.ipa
*.xcworkspace
*.xcuserstate // <--- Here
!default.xcworkspace

回答by Anthony

Nothing worked but this for me, as I wanted to commit Pods that also have .xcuserdata in it:

除了这个对我来说什么都没有用,因为我想提交也有 .xcuserdata 的 Pod:

**/xcuserdata/*

回答by bibscy

You could simply do

你可以简单地做

 git checkout -- <file>..." to discard changes in working directory

Example:

例子:

   modified:
        mySwa.com.xcworkspace/xcuserdata/bibscy.xcuserdatad/UserInterfaceState.xcuserstate

   git checkout -- mySwa.com.xcworkspace/xcuserdata/bibscy.xcuserdatad/UserInterfaceState.xcuserstate

回答by pmckeown

Coming late to this question but this site helped me out with this problem:

这个问题来晚了,但这个网站帮我解决了这个问题:

https://www.gitignore.io/

https://www.gitignore.io/

Specifically using the labes swiftand xcodeto generate the following:

具体使用实验室swiftxcode生成以下内容:

https://www.gitignore.io/api/xcode,swift

https://www.gitignore.io/api/xcode,swift

回答by AlexR

I don't see any logic here. However, in my case only moving xcuserdata/to the most down of the .gitignore file helped.

我在这里看不到任何逻辑。但是,在我的情况下,仅移动 xcuserdata/到 .gitignore 文件的最下方有帮助。

回答by Tylerc230

FWIW, my xcuserdata folder was NOT being tracked by git yet and was still showing up in git status. The problem was that I had a space before xcuserdatain my .gitignore file.

FWIW,我的 xcuserdata 文件夹还没有被 git 跟踪,并且仍然出现在git status. 问题是我之前xcuserdata在我的 .gitignore 文件中有一个空格。