Xcode 4 Git——“此文件在请求的修订版中不存在”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7101096/
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
Xcode 4 Git—"This file does not exist at the requested revision"
提问by FeifanZ
I have a local git repository that I set up with a project in Xcode 4. The repository shows up fine in the Organizer and I can see commit histories and Source Control icons in the File Navigator. Commits work fine as well. However, when I use the version editor, I get the error "This file does not exist at the requested revision"whenever I try to see any previous revision. I can't find any information on this error and have no idea how to fix. git log
shows four recent commits (I know there are more, but I don't know if this is a restriction of the command or if something's disappearing). Any ideas?
我有一个本地 git 存储库,我在 Xcode 4 中设置了一个项目。该存储库在管理器中显示良好,我可以在文件导航器中看到提交历史和源代码管理图标。提交工作也很好。但是,当我使用版本编辑器时,每当我尝试查看任何以前的修订版时,都会收到错误“此文件在请求的修订版中不存在”。我找不到有关此错误的任何信息,也不知道如何解决。git log
显示最近的四次提交(我知道还有更多,但我不知道这是命令的限制还是某些东西正在消失)。有任何想法吗?
采纳答案by FeifanZ
Still no answer; I've had to do some major changes the project anyway so I started a new project. All is well.
仍然没有答案;无论如何,我不得不对项目进行一些重大更改,因此我开始了一个新项目。一切都很好。
回答by Tad
I just ran into this same problem. I think (in my case anyway) that it was related to the fact that I had move the project directory outside of xcode. I believe xcode had cached some index files off in ~/Library somewhere. They seem to have gotten tangled up by the move.
我刚刚遇到了同样的问题。我认为(无论如何在我的情况下)这与我将项目目录移到 xcode 之外的事实有关。我相信 xcode 已经在 ~/Library 的某个地方缓存了一些索引文件。他们似乎被这个举动缠住了。
The fix (for me) was to open xcode, open the organizer->projects pane and find the project in question. Delete the derived data (there is a button in the upper right pane for this).
修复(对我而言)是打开 xcode,打开组织者-> 项目窗格并找到有问题的项目。删除派生数据(右上窗格中有一个按钮)。
After this, everything seemed fine.
在此之后,一切似乎都很好。
回答by freytag
This helped for me:
这对我有帮助:
- Go to XCode -> Organizer -> Repositories
- Remove all repositories, with the name written in red (i.e. File not found)
- Tap the "+" button in the lower left -> "Add Repository..."
- Enter the requested information: Path =
file://....<full path, which contains the .git directory>
. Make sure to have Type set to "Git", Xcode changed it to "Subversion", ignore the message "Authentication required" - Done
- 转到 XCode -> 管理器 -> 存储库
- 删除所有存储库,名称为红色(即找不到文件)
- 点击左下角的“+”按钮->“添加存储库...”
- 输入请求的信息:Path =
file://....<full path, which contains the .git directory>
。确保将 Type 设置为“Git”,Xcode 将其更改为“Subversion”,忽略消息“Authentication required” - 完毕
回答by Jim T
I encountered this when I changed case in a class name. Git had a lower case letter where I wanted upper case. I tried many of the things above shy of completely rebuilding the repository. I finally simply removed the class from the project, changed the name slightly then re-added it.
我在更改类名中的大小写时遇到了这个问题。Git 有一个小写字母,我想要大写字母。我尝试了很多上面的东西,以避开完全重建存储库。我最终只是从项目中删除了这个类,稍微更改了名称,然后重新添加了它。
回答by user2015453
It turned out, in my case, that this problem had something to do with the fact that I renamed a lot of files in my repository from "CamelCase" to "lowercase", including my project file and folder. This must have been improperly tracked somewhere somehow.
结果证明,就我而言,这个问题与我将存储库中的许多文件从“CamelCase”重命名为“小写”有关,包括我的项目文件和文件夹。这一定是在某处被错误地跟踪了。
OS X uses a case-insensitive filesystem by default, whereas git is internally case-sensitive, and I believe the problem had something to do with this.
OS X 默认使用不区分大小写的文件系统,而 git 内部区分大小写,我相信问题与此有关。
These are the steps I used to fix this. If you believe your problem may be due to changing the case of filenames, this may help you too.
这些是我用来解决这个问题的步骤。如果您认为您的问题可能是由于更改了文件名的大小写所致,这也可能对您有所帮助。
- Go to the root of your repository, and remove everything from it except for the .git folder using the "ls -la" (to see all the hidden files too) and "rm"/"rm -rf" commands.
- Do a "git reset --hard" to get all your files back. You may now see that the case of your filenames have changed. In my case, in the root of my working copy, "myapp.xcodeproj" and "myapp" (folder containing all the code files) had changed to "MyApp.xcodeproj" and "MyApp" (folder). I thought I had changed it to lowercase, but apparently, this hadn't been tracked properly by git.
- Now, rename your files to something unrelated. For instance, I renamed "MyApp.xcodeproj" to "foo.xcodeproj" and "MyApp" to "foo".
- Then do "git add --all"
- Now, rename your files to what you want. I renamed "foo.xcodeproj" to "myapp.xcodeproj" and "foo" to "myapp", which is how I wanted it to begin with (and what I thought I had already done).
- Do another "git add --all".
- Commit.
- 转到存储库的根目录,并使用“ls -la”(也可以查看所有隐藏文件)和“rm”/“rm -rf”命令从中删除除 .git 文件夹之外的所有内容。
- 执行“git reset --hard”以恢复所有文件。您现在可能会看到文件名的大小写已更改。就我而言,在我的工作副本的根目录中,“myapp.xcodeproj”和“myapp”(包含所有代码文件的文件夹)已更改为“MyApp.xcodeproj”和“MyApp”(文件夹)。我以为我已将其更改为小写,但显然,git 没有正确跟踪。
- 现在,将您的文件重命名为不相关的名称。例如,我将“MyApp.xcodeproj”重命名为“foo.xcodeproj”,将“MyApp”重命名为“foo”。
- 然后执行“git add --all”
- 现在,将您的文件重命名为您想要的名称。我将“foo.xcodeproj”重命名为“myapp.xcodeproj”,将“foo”重命名为“myapp”,这就是我希望它开始的方式(以及我认为我已经完成的操作)。
- 再做一次“git add --all”。
- 犯罪。
Now your life should be better and Xcode should behave well, because git is now seeing the exact same files (with the exact same case) as the Xcode project does.
现在你的生活应该更好,Xcode 应该表现良好,因为 git 现在看到与 Xcode 项目完全相同的文件(具有完全相同的案例)。
回答by Matt Montag
My problem and solution were simple:
我的问题和解决方案很简单:
- I had created a folder, myProj
- I created an Xcode project MyProj inside this folder
- This gave me a structure that looked like myProj/MyProj/MyProj/
- I didn't like that extra folder level, so I moved the inner MyProj out under myProj
- Xcode repository tracking got goofed up
- 我创建了一个文件夹 myProj
- 我在这个文件夹中创建了一个 Xcode 项目 MyProj
- 这给了我一个看起来像 myProj/MyProj/MyProj/ 的结构
- 我不喜欢那个额外的文件夹级别,所以我将内部的 MyProj 移到了 myProj 下
- Xcode 存储库跟踪被搞砸了
The solution:
解决方案:
- Open the Organizer to Repositories, and delete the upper case "MyProj" repository, which was highlighted in red. Xcode had detected the new repository location at "myProj" and resumed tracking things normally.
- 打开管理器到存储库,并删除大写的“MyProj”存储库,它以红色突出显示。Xcode 已在“myProj”中检测到新的存储库位置并恢复正常跟踪。
回答by MikeG
I'm guessing this is one of these problems that could be caused by multiple issues. This is mine and how I solved it.
我猜这是可能由多个问题引起的这些问题之一。这是我的,以及我是如何解决的。
My project had some file system name changes in progress. Namely, moving from all lower caps to Pascal casing. This got backed out at some point during my coding cycle. When I checked in, the file system was:
我的项目正在进行一些文件系统名称更改。即,从所有下盖移动到 Pascal 外壳。这在我的编码周期中的某个时候被取消了。当我签入时,文件系统是:
mydirectoryname
mydirectoryname
All the files under mydirectoryname
were no longer managed by git under Xcode. When viewing under the Version Editor, I ended up with the "This file does not exist at the requested version" error message.
mydirectoryname
Xcode下的所有文件都不再由git管理。在版本编辑器下查看时,我最终看到“请求的版本中不存在此文件”错误消息。
However, if I selected one of the files and clicked on the File Inspector (available in the Utilities pane), I noticed the full file path was listed as:
但是,如果我选择其中一个文件并单击文件检查器(在“实用程序”窗格中可用),我注意到完整的文件路径被列为:
MyRootPath/MyDirectoryName/TheCodeFile.h
MyRootPath/MyDirectoryName/TheCodeFile.h
I closed Xcode, opened the .pbxproj file in an editor, fixed the path, and reopened the project. Git integration was working once again.
我关闭了 Xcode,在编辑器中打开了 .pbxproj 文件,修复了路径,然后重新打开了项目。Git 集成再次发挥作用。
回答by Flavien Volken
As I know, it is due to a conflict that Xcode 4.3 currently do not handle correctly. I also had similar problem with a badly synchronized .DS_Store. I manually removed it and was stuck in a similar case.
据我所知,这是由于 Xcode 4.3 当前无法正确处理的冲突。我也有与严重同步的 .DS_Store 类似的问题。我手动删除了它并陷入了类似的情况。
I then had to manually solve the problem using the command line:
然后我不得不使用命令行手动解决问题:
- open the terminal
- cd to the local git repository
- cd .git/
- mv MERGE_HEAD MERGE_HEAD_OLD // or just delete it
- 打开终端
- cd 到本地 git 存储库
- 光盘.git/
- mv MERGE_HEAD MERGE_HEAD_OLD // 或者直接删除
If you were stuck with pull, commit and push, through Xcode you should be able to call them again. Moreover, as both sides should then be correctly synchronized, your error "This file does not exist at the requested revision" will be gone as well. Please comment if this worked for you.
如果您一直在使用 pull、commit 和 push,那么您应该可以通过 Xcode 再次调用它们。此外,由于双方应该正确同步,您的错误“此文件在请求的修订版中不存在”也将消失。如果这对您有用,请发表评论。
回答by Kibernetik
Had the same problem.
Solved by selecting the project in "Projects" page of Organizer and deleting both "Derived Data" and "Snapshots" data by pressing "Delete..." buttons for these fields.
After this, new snapshot can be successfully created and exported if necessary.
有同样的问题。
通过在管理器的“项目”页面中选择项目并通过按这些字段的“删除...”按钮删除“派生数据”和“快照”数据来解决。
之后,如果需要,可以成功创建和导出新快照。
回答by followben
I came across the same error using Xcode 4.2 in a relatively new project earlier today.
今天早些时候,我在一个相对较新的项目中使用 Xcode 4.2 遇到了同样的错误。
I initially worked around the problem by cloning the repo into a sibling directory. In Terminal:
我最初通过将 repo 克隆到同级目录来解决这个问题。在终端:
> cd /path/to/XCodeProject
> mkdir ../Clone
> cd ../Clone
> git clone ../XCodeProject/.git .
However, when I removed the original project and renamed the new directory to the same name, the problem reappeared.
但是,当我删除原始项目并将新目录重命名为相同名称时,问题再次出现。
In the end, the workaround was simply to locate my .xcodeproj and .git files and give the parent directory a different name.
最后,解决方法只是找到我的 .xcodeproj 和 .git 文件并为父目录指定不同的名称。
回答by rsam
This is an ancient thread, but since a proper answer was never found, I will throw in my 2 cents.
这是一个古老的线程,但由于从未找到正确的答案,我将投入 2 美分。
One cause for this error can come from untracked files, specifically from a submodule or files that are not present in the current branch but where in a previous one.
此错误的一个原因可能来自未跟踪的文件,特别是来自当前分支中不存在但在前一个分支中的子模块或文件。
For example, when you switch to a branch with a submodule and update such submodule, it will sync those files to your repository. When you later switch to a branch that does not have such submodule, it won't add or delete them automatically, but git will realize that something is not tracked in the branch. XCode detects this too whenever you switch to any of the Version Editor modes: log, blame, or comparison.
例如,当您切换到带有子模块的分支并更新此类子模块时,它会将这些文件同步到您的存储库。当您稍后切换到没有此类子模块的分支时,它不会自动添加或删除它们,但是 git 会意识到分支中没有跟踪某些内容。每当您切换到任何版本编辑器模式时,XCode 也会检测到这一点:记录、责备或比较。
If this is the case, a git status prompt will yield the untracked files:
如果是这种情况,git status 提示将生成未跟踪的文件:
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
yourSubmodule/
nothing added to commit but untracked files present (use "git add" to track)
To fix this, you can simply delete the untracked files with rm, since those files do not belong to this branch and can be synced from the branch that actually points to the submodule. Note this is the case of the submodule, but if you do have new files you should add them to the repository instead, or alternatively adding them to the ignore list. After fixing the problem, git status should be clean:
要解决此问题,您可以简单地使用rm删除未跟踪的文件,因为这些文件不属于该分支,并且可以从实际指向子模块的分支同步。请注意,这是子模块的情况,但如果您确实有新文件,则应将它们添加到存储库中,或者将它们添加到忽略列表中。修复问题后,git status 应该是干净的:
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
Read about submodulesand issues with their usage.
Cheers!
干杯!