【发布时间】:2021-01-29 10:14:04
【问题描述】:
我有一个主“app”文件夹,它是 git 存储库的根目录。在这里,我有“ios-app”文件夹,我的 Xcode xcworkspace 位于“android-app”、“backend”等其他文件夹中。令人惊讶的是,Xcode 确实显示了文件的状态(即 M 表示已修改),而我能够使用 Fetch Changes 菜单选项,但我无法使用 Xcode 提交或在代码审查编辑器中查看文件。
打开代码预览时出错:
The source control operation failed because the file “...” could not be found.
Make sure a valid file exists in the repository and try again.
提交时出错:
The working copy “...” failed to commit files.
error: pathspec 'app/ios-app/DataModel/EventMutations.swift' did not match any file(s) known to git
在控制台应用程序中没有什么有趣的,但以下详细信息可能是相关的:
[MT] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-17220/IDEKit/CommandsAndSelection/IDEMenuBuilder.m:203
Details: Unknown submenu: "Xcode.IDEPegasusSourceEditor.MenuDefinition.SourceCodeAuxiliaryEditorMenuItem3" in menu: "Xcode.IDEPegasusSourceEditor.MenuDefinition.Editor"!
Object: <IDEMenuBuilder>
Method: +_menuItemForMenuItemElement:inMenuWithIdentifierUsedForDebugging:forViewController:fillingExtensionIdToMenuMap:
Thread: <NSThread: 0x7fb3aa517540>{number = 1, name = main}
Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide.
在某一时刻,我确实将我的文件夹从“iOS-app”重命名为“ios-app”,以排除这可能是 git 区分大小写的情况,我确实运行了 git config --global core.ignorecase true,但这并不能解决问题.
我还尝试从 Xcode 的“欢迎使用 Xcode”页面中删除该项目并重新添加它们,以防这会影响 gitpath 的确定方式。
Xcode 中的所有文件路径似乎都是正确的,并且“在文件夹中显示”选项始终有效。
我还能够在源代码管理导航中正确查看 git 项目:
【问题讨论】:
-
文件存在于本地还是远程?另外,您的目录中是否有该文件的特殊字符?包括空格?由于我的目录中有空间,我过去曾把它扔掉。
-
本地和远程都没有特殊字符以及我的文件。我正在从本地文件夹中打开项目。
-
啊...刚发现我的遥控器和本地的情况不同,不知道这会不会影响它?!
-
是的,绝对会影响它。最好的办法是隐藏您的更改,然后拉动并尝试将这些更改拼凑在一起。希望你不是 1000 行,哈哈。
-
您是否忘记将上游设置为原点?