git Git如何退出rebase模式

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

Git how to exit rebase mode

git

提问by user1615666

I did a Git rebase, fixed the conflict and force pushed already, why it is still rebase mode, "dev|REBASE 2/3" ? how to exit it ? I don't want to throw away the rebase.

我做了一个 Git rebase,修复了冲突和强制推送,为什么它仍然是 rebase 模式,“dev|REBASE 2/3”?怎么退出呢?我不想扔掉变基。

aaa@lenovo-pc MINGW64 ~/Documents/NetBeansProjects/GitTest1 (dev|REBASE 2/3)
$ git status
rebase in progress; onto f67f4c5
You are currently rebasing branch 'dev' on 'f67f4c5'.
  (all conflicts fixed: run "git rebase --continue")

nothing to commit, working tree clean

aaa@lenovo-pc MINGW64 ~/Documents/NetBeansProjects/GitTest1 (dev|REBASE 2/3)
$ git push --force origin dev
[email protected]'s password:
Everything up-to-date

aaa@lenovo-pc MINGW64 ~/Documents/NetBeansProjects/GitTest1 (dev|REBASE 2/3)

Thanks

谢谢

回答by Xobb

git rebase --abort

this should do the trick for you.

这应该对你有用。

UPD:

更新:

git revert is somewhat "atomic" operation. You cannot finish it in the middle. Think of it as of the transaction. It either finishes or not. If you think that you're finished, but your working copy is still in "rebase" mode than means you've done something wrong, i.e.:

git revert 有点“原子”操作。你不能在中间完成它。把它想象成交易。它要么完成,要么不完成。如果你认为你已经完成了,但你的工作副本仍然处于“rebase”模式,这意味着你做错了什么,即:

  • Manually added the commit with git commit
  • Didn't resolve the conflict if that was the case. Usually rebase is an automatic operation that you just run and watch, it stops only when the conflict is not resolved.
  • 手动添加提交 git commit
  • 如果是这种情况,则无法解决冲突。通常 rebase 是一个你运行和观察的自动操作,它只有在冲突没有解决时才会停止。

How to resolve a conflict? Well, that is a good separate question.

如何解决冲突?嗯,这是一个很好的单独问题。

回答by Tim Biegeleisen

I have generally found that simply following the instructions which prompts to you during the rebase process usually doesn't go wrong. Based on the snippet you showed us, which says:

我通常发现,只需按照在 rebase 过程中提示的说明操作通常不会出错。根据您向我们展示的片段,其中说:

(all conflicts fixed: run "git rebase --continue")

your next move probably should have been to run git rebase --continueto finish the rebase, or at least move to the next applied commit.

您的下一步可能应该是运行git rebase --continue以完成 rebase,或者至少移动到下一个应用的提交。

What to do now:

现在做什么:

Instead of completing/continuing with the rebase, you force pushed the devbranch to the remote. Since you would likely have to force push this anyway after the rebase, I don't see any long term harm being done. So you should just complete the rebase by doing

您没有完成/继续 rebase,而是强制将dev分支推送到远程。由于您可能不得不在 rebase 之后强制推送此内容,因此我认为不会造成任何长期伤害。所以你应该通过做来完成rebase

git rebase --continue

and then force push again once the rebase is actually completed.

然后在 rebase 实际完成后再次强制推送。

By the way, if you decide that you really want to throw away the rebase, you can do so via

顺便说一句,如果你决定你真的想扔掉 rebase,你可以通过

git rebase --abort

回答by Vinoth Vino

You can exit from rebase mode by the following command git rebase --abort

您可以通过以下命令退出 rebase 模式 git rebase --abort