我以为我已经把 Xcode + git 问题的日子抛在脑后了。可能不会。尝试 checkout 另一个分支时出现此 git 错误。
error: The following untracked working tree files would be overwritten by checkout:
RCAlpha.xcodeproj/project.xcworkspace/xcuserdata/andrewjl.xcuserdatad/UserInterfaceState.xcuserstate
RCAlpha.xcodeproj/xcuserdata/andrewjl.xcuserdatad/xcschemes/RCAlpha.xcscheme
RCAlpha.xcodeproj/xcuserdata/andrewjl.xcuserdatad/xcschemes/xcschememanagement.plist
Please move or remove them before you can switch branches.
Aborting
好吧,让我删除这些文件:
andrewjl$ git rm --cached RCAlpha.xcodeproj/project.xcworkspace/xcuserdata/andrewjl.xcuserdatad/UserInterfaceState.xcuserstate
fatal: pathspec 'RCAlpha.xcodeproj/project.xcworkspace/xcuserdata/andrewjl.xcuserdatad/UserInterfaceState.xcuserstate' did not match any files
此时我不确定该怎么做。这些文件都列在我的 .gitignore
中,我也试了一下 git clean -f -d
。没有骰子。有人知道这里发生了什么吗?
最佳答案
文件未被跟踪:git rm --cached
找不到它们,因为索引中没有。只需使用您的文件管理器或 rm
删除它们。然后 checkout 应该按预期工作。请注意,git status
将向您显示 git 将文件视为什么(已跟踪、已更改、未跟踪;还有一个附加选项,它还会显示被忽略的文件)。
关于xcode - 由于未跟踪的工作树文件导致 git branch checkout 出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13783168/