git 错误:源代码管理操作失败,因为修订

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

Error: The source control operation failed because the revisions

gitxcode7

提问by Franck

I've installed Xcode 7, and now always get this message when I select "commit" from xcode menu.

我已经安装了 Xcode 7,现在当我从 xcode 菜单中选择“提交”时总是收到这条消息。

"The source control operation failed because the revisions... could not be found."

“源代码控制操作失败,因为无法找到修订版……”

Any idea? :)

任何的想法?:)

error message

错误信息

回答by VonC

That could happen if the state of the git repo isn't proper:

如果 git repo 的状态不正确,可能会发生这种情况:

  • file outside if a git repo, or
  • no commit yet (initial first commit), or
  • no files added to the index
  • 如果是 git 存储库,则在外部文件,或
  • 还没有提交(最初的第一次提交),或者
  • 没有文件添加到索引

(there was also repo of XCode 7 crashing on git commit)

(还有一个XCode 7 的repo在 git commit 上崩溃

Go to the parent folder of the modified file, and to a git status, to check what is actually going on.
Check also (just after seeing that error message) the /Applications/Utilities/Console.appin case there are more clues (as it was done before for this other error bug report)

转到修改文件的父文件夹,然后转到 a git status,检查实际发生的情况。
还检查(在看到该错误消息后)/Applications/Utilities/Console.app以防有更多线索(就像之前针对此其他错误错误报告所做的那样)

回答by Colíbri

I had the same situation. In my case, with several files I got the error for any git related operation and other files it worked fine.

我有同样的情况。在我的例子中,有几个文件我得到了任何与 git 相关的操作和其他文件的错误,它工作正常。

Finally I found that those file paths were a little bit wrong on Xcode "File Inspector" view. The file path I saw was like "Foo/foo.m" but actually it must be "foo/foo.m". I clicked the folder icon and select the file again. Then Xcode shows the correct path and I've got working.

最后我发现这些文件路径在 Xcode“文件检查器”视图中有点错误。我看到的文件路径类似于“Foo/foo.m”,但实际上它必须是“foo/foo.m”。我单击文件夹图标并再次选择该文件。然后 Xcode 显示正确的路径,我开始工作了。

I hope this helps someone's situation too.

我希望这也有助于某人的情况。

回答by Aaron

If you have Version Editor > Blame turned on, turn it off. You can do this by clicking the button with the lines (highlighted) to show the Standard Editor again. Here's a screen shot:

如果您打开了 Version Editor > Blame,请将其关闭。您可以通过单击带有线条(突出显示)的按钮再次显示标准编辑器来执行此操作。这是一个屏幕截图:

enter image description here

在此处输入图片说明

回答by Mick

It is in the wrong folder!

它在错误的文件夹中!

This is due to your localization .stringsfile not being in the correct folder.

这是因为您的本地化.strings文件不在正确的文件夹中。

When you create the localization file for your Base, make sure to put it in Base.lprojfolder, like so:

为 Base 创建本地化文件时,请确保将其放在Base.lproj文件夹中,如下所示:

][Add Localizable.strings in correct folder1

][ 在正确的文件夹中添加 Localizable.strings1

The above assumes you are using Base Internationalization:

以上假设您正在使用基本国际化:

enter image description here

在此处输入图片说明

For a great reference, take a quick look at iOS Localization Tutorial.

要获得很好的参考,请快速查看iOS 本地化教程

回答by chikko

Same thing happend to me. Xcode claimed of failing to find a revision of a file while trying to commit - even though i was able to see its previous versions using the Comparisonand Blameviews.

同样的事情发生在我身上。Xcode 声称在尝试提交时未能找到文件的修订版 - 即使我能够使用比较责备视图查看其以前的版本。

enter image description here

在此处输入图片说明

The solution was restarting Xcode. Everything magically worked afterwards, and i was able to commit the project, including the problematic file.

解决方案是重新启动 Xcode。之后一切都神奇地工作了,我能够提交该项目,包括有问题的文件。

回答by Uilleann

I had the same problem. The problem was the file path stored in XCode. When I looked at the full path in the file inspector it was incorrect. Removing the troublesome files from the project and re-adding them fixed it for me.

我有同样的问题。问题是存储在 XCode 中的文件路径。当我在文件检查器中查看完整路径时,它是不正确的。从项目中删除麻烦的文件并重新添加它们为我修复了它。

回答by Monkey King

the reason is that you change the .h/.m file 's path or name, so the source control operation couldn't know the repository.

原因是您更改了 .h/.m 文件的路径或名称,因此源代码控制操作无法知道存储库。

To solve that problem ,you just remove reference and add file to the project again. There will be an amazing result happening.

要解决该问题,您只需删除引用并再次将文件添加到项目中。会有惊人的结果发生。