删除/修改冲突后,Git rebase 将不会继续
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5516391/
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
Git rebase will not continue after a delete/modify conflict
提问by Clutch
I'm in the middle of a rebase of my master to a stage branch
我正在将我的主人变基到舞台分支
git checkout stage
git rebase master
At some time I deleted two files then modified the two files according to GIT.
有时我删除了两个文件,然后根据 GIT 修改了这两个文件。
warning: too many files, skipping inexact rename detection
CONFLICT (delete/modify): test-recommendation-result.php deleted in HEAD and modified in [Bug] Fix test recommender. Version [Bug] Fix test recommender of test-recommendation-result.php left in tree.
CONFLICT (delete/modify): test-recommendation.php deleted in HEAD and modified in [Bug] Fix test recommender. Version [Bug] Fix test recommender of test-recommendation.php left in tree.
Failed to merge in the changes.
Patch failed at 0015.
I want to say "Yeah git, go ahead and delete those files" so ....
我想说“是的,git,继续删除这些文件”所以......
git rm test-recommendation-result.php
git rm test-recommendation.php
git rebase --continue
Git says:
Git 说:
Applying [Bug] Fix test recommender
No changes - did you forget to use 'git add', Stupid?
When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".
I say "Don't call me "Stupid" and just do what I told you to do!"
我说“不要叫我“笨蛋”,按我说的去做!
We are now at a standoff. Who is right and how do I fix this?
我们现在处于对峙状态。谁是对的,我该如何解决这个问题?
回答by Adam Dymitruk
do git add -A
followed by git rebase --continue
. This should add all changes - including your removal of the files and then continue.
git add -A
接着做git rebase --continue
。这应该添加所有更改 - 包括您删除文件,然后继续。
There is no guarantee that the commit didn't have other files that did not conflict and should be merged. git rebase --skip
would lose those files. You don't want that.
不能保证提交没有其他不冲突且应该合并的文件。git rebase --skip
会丢失那些文件。你不想那样。
Hope this helps.
希望这可以帮助。
回答by Josh Lee
When all else fails, read the message.
当所有其他方法都失败时,请阅读消息。
This patch is trying to modify two files, but they have already been deleted; deleting them again did nothing.
这个补丁试图修改两个文件,但它们已经被删除了;再次删除它们什么也没做。
Just run git rebase --skip
.
就跑git rebase --skip
。
回答by Guy Lancaster
I hit this when a commit added a binary file that conflicted with an existing file.
当提交添加了一个与现有文件冲突的二进制文件时,我遇到了这个问题。
I got by it by:
我是通过以下方式解决的:
- deleting the existing file,
- making a single character change to a comment in a different file, and
- "git add" ing that irrelevant change.
- 删除现有文件,
- 对不同文件中的注释进行单个字符更改,以及
- “git add” 表示无关的更改。
Git was happy again. :)
吉特又高兴起来了。:)
回答by GuyPaddock
There is not one magic sequence of commands to always run to solve this situation. If there were, GIT's developers would just perform that action and not bother the user.
没有一个神奇的命令序列可以始终运行来解决这种情况。如果有的话,GIT 的开发人员只会执行该操作,而不会打扰用户。
Consider that this error can also happen if you're cherry picking / transplanting / backporting changes that affect a file that was re-factored or renamed.
考虑到如果您正在挑选/移植/向后移植影响重构或重命名的文件的更改,也可能发生此错误。
For example, say that you have branch called support/1.0
that looks like this:
例如,假设您调用support/1.0
了如下所示的分支:
com.somewhere.package-a/ MyClass.java MyOtherClass.java
Now, suppose that between versions 1.0 and 1.5, this got refactored. So now release/1.5
looks like this:
现在,假设在 1.0 和 1.5 版本之间,这被重构了。所以现在release/1.5
看起来像这样:
com.somewhere.package/ a/ MyClass.java ANewClass.java b/ MyOtherClass.java
Now, let's say that you have a feature branch from release 1.5 that you're trying to back-port to a feature branch based off of support/1.0
. In that commit, there were changes to all three files from release 1.5 (MyClass.java
, ANewClass.java
, and MyOtherClass.java
).
现在,假设您有一个 1.5 版的功能分支,您正尝试将其移植到基于support/1.0
. 在那次提交,共有来自1.5版的变化对所有三个文件(MyClass.java
,ANewClass.java
,和MyOtherClass.java
)。
If you try to use rebase or plain cherry pick to help with the back-port, one of two things may happen:
如果您尝试使用 rebase 或普通的cherry pick 来帮助进行反向移植,则可能会发生以下两种情况之一:
If the files got renamed as part of the changes being transplanted, or among the immediate parent commits of the changes being transplanted, GIT's built-in rename detection may catch that these files are descendants of the files with original names, and simply apply the changes to the original files.
If the files got renamed sufficiently far back in the history of release 1.5 (after release 1.0 shipped), GIT will tell you that the files were deleted in
release/1.0
because it doesn't know what files in 1.0 correspond to the changes from 1.5.
如果文件被重命名为被移植更改的一部分,或者在被移植更改的直接父提交中,GIT 的内置重命名检测可能会发现这些文件是具有原始名称的文件的后代,并且只需应用更改到原始文件。
如果文件在 1.5 版的历史中被重命名足够远(在 1.0 版发布之后),GIT 会告诉你文件被删除了,
release/1.0
因为它不知道 1.0 中的哪些文件对应于 1.5 的更改。
ANewClass.java
will almost certainly trigger the error about having been deleted, unless it was added in one of the changes being back-ported.
ANewClass.java
几乎肯定会触发关于已被删除的错误,除非它是在向后移植的更改之一中添加的。
Hence, because code might get lost if you blindly follow one set of commands to resolve this situation, that's why GIT prompts you for manual guidance.
因此,因为如果您盲目地遵循一组命令来解决这种情况,代码可能会丢失,这就是 GIT 提示您手动指导的原因。
回答by x-magix
as my problem:
作为我的问题:
when I did git add .
all of my changes disappeared. I needed to change any document (just to add little change, for example adding comment) and do git add .
than git rebase --continue
worked for me. It is a know bug with git
当我这样做时,我的git add .
所有更改都消失了。我需要改变任何文件(我想补充一点变化,例如添加注释),并做git add .
不是git rebase --continue
对我来说有效。这是 git 的一个已知错误