git rebase --continue 不起作用

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

git rebase --continue won't work

gitgit-rebase

提问by Boon

I did git rebase master, fixed the conflicts reported in a file, and then git addthe file to resolve the conflict. Then I did git rebase --continue, and got this:

我做了git rebase master,修复了文件中报告的冲突,然后git add解决了文件中的冲突。然后我做了git rebase --continue,得到了这个:

Applying: Fixed unit test

No changes - did you forget to use 'git add'? If there is nothing left to stage, chances are that something else already introduced the same changes; you might want to skip this patch.

When you have resolved this problem, run "git rebase --continue". If you prefer to skip this patch, run "git rebase --skip" instead. To check out the original branch and stop rebasing, run "git rebase --abort".

应用:固定单元测试

没有变化 - 您是否忘记使用“git add”?如果没有任何东西可以上演,很可能其他东西已经引入了相同的变化;你可能想跳过这个补丁。

解决此问题后,运行“git rebase --continue”。如果您更喜欢跳过此补丁,请改为运行“git rebase --skip”。要检查原始分支并停止变基,请运行“git rebase --abort”。

Any idea what I am missing here? Should I do git rebase --skip?

知道我在这里缺少什么吗?我应该做 git rebase --skip 吗?

采纳答案by janos

If you are in Mac OS X, then first of all you should disable revisiond, as it can mess with files in your work tree in the middle of rebase, causing unpredictable and broken behavior:

如果您使用的是 Mac OS X,那么首先您应该禁用revisiond,因为它可能会在变基中间弄乱您工作树中的文件,从而导致不可预测和损坏的行为:

git config --global core.trustctime false

The issue is explained in this article, and big thanks to @nickfalkwho pointed it out.

这个问题在这篇文章中有解释,非常感谢@nickfalk指出它。

As for your rebase, this kind of situation is not unusual in practice. Let's try to think through the steps of what's happening:

至于你的rebase,这种情况在实践中并不少见。让我们试着思考一下发生了什么的步骤:

  • When you rebase the current branch on top of another branch, git moves the HEAD to the other branch, and starts applying the unique commits you have in your current branch.

  • While replaying one of those commits, you reached a conflict. You resolved it, but as a result there are no changes to commit, nothing to replay in this commit.

  • 当您将当前分支变基到另一个分支的顶部时,git 会将 HEAD 移动到另一个分支,并开始应用您在当前分支中的唯一提交。

  • 在重播其中一个提交时,您遇到了冲突。您解决了它,但结果是没有更改要提交,在此提交中没有可重播的内容。

Practically, this means that you rejected the changes in the current commit being replayed. So, if you don't need anything from this commit, it's normal to skip it. So git rebase --skipmakes sense here.

实际上,这意味着您拒绝了正在重放的当前提交中的更改。因此,如果您不需要此提交中的任何内容,则跳过它是正常的。所以git rebase --skip在这里是有道理的。

回答by T. Benjamin Larsen

Breath, you're not going crazy! ;-= This is a known bug where OSX (if that is indeed what you're using) is messing with git, it is detailed here(not by me).

呼吸,你不会发疯!; - =这是一个已知的bug,其中OSX(如果这确实是你所使用的)与git的,它详细搞乱这里(不是我)。

Short story (i.e. the fix) is:

短篇小说(即修复)是:

git config --global core.trustctime false

回答by Eliseu Egewarth

I had a similar problem in my project and solved by putting the --preserve-mergesoption to the rebase command. In my project, this problem was caused by a merge commit, which is an "empty commit". Using git rebase --preserve-mergesit takes the merge commit and continues the merge without breaking the commit tree.

我在我的项目中遇到了类似的问题,并通过将--preserve-merges选项放入rebase 命令来解决。在我的项目中,这个问题是由合并提交引起的,它是一个“空提交”。使用git rebase --preserve-merges它需要合并提交并继续合并而不破坏提交树。

回答by Vino

I tried all the methods but nothing worked for me. If you are not in the middle of a rebase but git keeps complaining, then try the following. This worked for me for OSX.

我尝试了所有方法,但对我没有任何效果。如果您不在 rebase 中,但 git 一直在抱怨,请尝试以下操作。这对我来说适用于 OSX。

rm -fr ".git/rebase-apply"

rm -fr ".git/rebase-apply"

回答by Gi0rgi0s

None of the above suggestions worked. I found out that I had this issue because I did a hard reset of the master branch, while my feature branch had some legacy master commits (don't asked me how - no idea :( ).

上述建议均无效。我发现我遇到了这个问题,因为我对 master 分支进行了硬重置,而我的 feature 分支有一些遗留的 master 提交(不要问我如何 - 不知道 :( )。

I copied my changes out to a temporary directory, deleted my feature branch, copied them back in, and restarted from scratch. Ugly but effective. Not suggested if you're trying to keep more than one commit in your feature branch. Not suggested unless you have tried EVERYTHING ELSE.

我将更改复制到一个临时目录,删除了我的功能分支,将它们复制回,然后从头开始。丑陋但有效。如果您尝试在功能分支中保留多个提交,则不建议这样做。不建议,除非您已经尝试了其他一切

UPDATE: This worked, but a better approach has been pointed out to me in the comments below. Take a look.

更新:这有效,但在下面的评论中向我指出了更好的方法。看一看。

回答by Neo

It could well mean that the changes are already rebased. Just check the git status.

这很可能意味着更改已经重新定位。只需检查 git 状态。