42

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

I have the following .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:

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

Does anybody have any idea what's wrong?

4

10 回答 10

47

我找到了解决方案

问题不在 .gitignore 文件中

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

不能忽略 UserInterfaceState.xcuserstate

于 2013-03-26T20:10:17.013 回答
10

附加信息

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

.... .gitignore 无法读取此内容:

xcuserdata/*

添加这对我有用:

*xcworkspace/xcuserdata/*

或阅读:

*/xcuserdata/*
于 2015-10-02T02:15:24.597 回答
3

除了添加*.xcuserstate到您的.gitignore文件之外,请记住删除您的缓存*.xcuserstate

git rm --cached [YourProjectName].xcodeproj/project.xcworkspace/xcuserdata/[ YourUsername].xcuserdatad/UserInterfaceState.xcuserstate

https://www.programmersought.com/article/1594916500/

于 2021-05-07T17:46:40.720 回答
3

如果你使用过 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
于 2018-12-05T02:23:26.890 回答
3

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

于 2020-05-03T21:53:06.693 回答
2

除了这对我来说没有任何效果,因为我想提交其中也有 .xcuserdata 的 Pod:

**/xcuserdata/*
于 2019-06-10T12:54:39.347 回答
1

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

将此行添加到您的 gitignore

*.xcuserdata
于 2018-06-05T10:13:07.577 回答
1

迟到了这个问题,但这个网站帮助我解决了这个问题:

https://www.gitignore.io/

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

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

于 2020-04-27T06:28:16.017 回答
0

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

于 2015-02-04T16:34:37.350 回答
-1

你可以简单地做

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

例子:

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

   git checkout -- mySwa.com.xcworkspace/xcuserdata/bibscy.xcuserdatad/UserInterfaceState.xcuserstate
于 2019-06-19T07:47:36.767 回答