xcode 由于未跟踪的工作树文件而导致 git branch checkout 出现问题

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

Issues with git branch checkout due to untracked working tree files

xcodegitversion-control

提问by Andrew Lauer Barinov

I thought I put the days of Xcode + git issues behind me. Guess not. I am getting this git error when trying to checkout another branch.

我以为我已经把 Xcode + git 问题抛在脑后了。可能不会。尝试结帐另一个分支时出现此 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

Very well I say, let me remove these files:

我说得很好,让我删除这些文件:

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

At this point I'm not sure what to do. These files are all listed in my .gitignoreand I also gave git clean -f -da try as well. No dice. Anyone know what's going on here?

在这一点上,我不知道该怎么做。这些文件都在我的列表中.gitignore,我也git clean -f -d试了一下。没有骰子。有谁知道这里发生了什么?

采纳答案by Nevik Rehnel

The files are untracked: git rm --cachedcannot find them because there are not in the index. Just delete them, using your file manager or rm. Then checkout should work as expected. Note that git statuswill show you what git sees the files as (tracked, changed, untracked; with an additional option it will also display ignored files).

文件未跟踪:git rm --cached无法找到它们,因为索引中没有。只需使用文件管理器或rm. 然后结帐应该按预期工作。请注意,这git status将显示 git 将文件视为什么(已跟踪、已更改、未跟踪;使用附加选项,它还将显示被忽略的文件)。

回答by Daij-Djan

they arent in git but there locally .. that means when you switch those would be lost and git doesnt allow that

它们不在 git 中,但在本地 .. 这意味着当你切换它们时,它们会丢失并且 git 不允许这样做

remove them locally:

在本地删除它们:

rm 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

they are recreated by xcode anyway. nothing important in there!

无论如何,它们都是由 xcode 重新创建的。没有什么重要的!

回答by Sreeraj VR

Try this

尝试这个

git rm --cache */xcschemes/xcschememanagement.plist

git rm --cache */xcschemes/xcschememanagement.plist

git commit -m "Good bye xcschememanagement.plist"

git commit -m "再见 xcschememanagement.plist"

回答by Ramdhas

Git stash and git checkout "yourBranch"

Git stash 和 git checkout "yourBranch"