git Egit - 现在无法结帐 - 卡在 rebase 状态

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

Egit - Cannot checkout now - stuck in rebase state

eclipsegitgithubmerge

提问by Cydhra

I asked a similar question a few days ago, but I did not get a helpful answer, so I want to make everything more precise.

几天前我问了一个类似的问题,但我没有得到有用的答案,所以我想让一切都更精确。

I have a big project as a private repo on github. A friend of mine and me are currently working on it. I imported the whole repo into a local repository and into eclipse and everything went fine, until the merging conflicts came up. Everytime, I get a merging conflict (e.g. when I forget to pull before working on often used classes), the whole project in my eclipse workspaces switches into a state "Rebase w/merge":

我有一个大项目作为 github 上的私人仓库。我和我的一个朋友目前正在研究它。我将整个 repo 导入到本地存储库和 eclipse 中,一切顺利,直到出现合并冲突。每次,我都会遇到合并冲突(例如,当我在处理常用类之前忘记拉取时),我的 Eclipse 工作区中的整个项目都会切换到“Rebase w/merge”状态:

Rebase w/merge state of the project

Rebase w/merge 项目的状态

Now I get marks were the merge conflicts came up. So I opened the class to merge with the merge tool, edited everything I had to change and added the class to index again.

现在我得到了合并冲突的分数。因此,我打开了该类以使用合并工具进行合并,编辑了我必须更改的所有内容并将该类再次添加到索引中。

Next, I commited all merging changes and pushed everything to the upstream into master-branch (we only use master so far, because we both do not have much experience with git and vcs/svn).

接下来,我提交了所有合并更改并将所有内容推送到上游到 master-branch(我们目前只使用 master,因为我们都没有太多的 git 和 vcs/svn 经验)。

But now, I neither can switch back to master branch, nor cancel rebase or do anything else.

但是现在,我既不能切换回 master 分支,也不能取消 rebase 或做任何其他事情。

I tried:

我试过:

Rightclick on project folder -> Team -> Switch To -> master. Checkout fail

右键单击项目文件夹 -> Team -> Switch To -> master。 结帐失败

That is the error notification.

那是错误通知。

Next I was told to cancel the rebase in Git Repositories View:

接下来我被告知在 Git Repositories View 中取消 rebase:

Git Repo View

Git 存储库视图

But neither my local repo nor the remote one has any option related to rebasing.

但是我的本地存储库和远程存储库都没有任何与变基相关的选项。

Next I tried "checkout" in the menu of the local branch. Same result. I also tried to push my local branch into the upstream:

接下来我在当地分店的菜单中尝试了“结账”。结果一样。我还尝试将我的本地分支推入上游:

enter image description here

在此处输入图片说明

This is my preset of the merge/rebase option, but both of those options bring up the same result:

这是我对合并/变基选项的预设,但是这两个选项都带来了相同的结果:

enter image description here

在此处输入图片说明

I looked into my repo in github - all of my changes including the merge resolve are already pushed into the master branch and are ready to fetch. My teammate can pull them and can continue working on the project. But I cannot escape this Rebase w/merge state. Everytime this state came up, I had to delete all project resources, delete the local repository, re-import everything into eclipse and finally, I had to do every additional configuration over and over again.

我查看了 github 中的 repo - 我的所有更改(包括合并解析)都已推送到主分支并准备好获取。我的队友可以拉动它们并继续进行项目。但是我无法摆脱这种带有合并状态的 Rebase。每次出现这种状态时,我都必须删除所有项目资源,删除本地存储库,将所有内容重新导入 eclipse,最后,我不得不一遍又一遍地进行所有其他配置。

So: How can I escape this rebase? And btw: What is the difference between rebase and merging?

所以:我怎样才能摆脱这个变基?顺便说一句:变基和合并有什么区别?

回答by Micha? Grzejszczak

In Git Stagingview there is an option to abort rebase.

Git Staging视图中有一个选项,以中止衍合。

enter image description here

在此处输入图片说明

回答by anand mishra

Use the Merge upstream commit to local branch.

使用合并上游提交到本地分支。

Rebase means changing the old master to new master code(i.e. changing the base of your branch) and merging means added your changes to master.

Rebase 意味着将旧的 master 更改为新的 master 代码(即更改分支的基础),合并意味着将您的更改添加到 master。

You can also try using git command line to resolve such conflict.

您也可以尝试使用 git 命令行来解决此类冲突。

Using Git Rebase/Merge Process While working on your brach get all files added and pushed to server

使用 Git Rebase/Merge Process 在你的分支上工作时,将所有文件添加并推送到服务器

git add .
git commit -m "SSSS"
git push -u origin <BranchName>
git checkout master
git pull

[A] The master is older code means you can merge your code

[A] master 是旧代码意味着您可以合并您的代码

git merge <your branch name>
git push

[B] Master has newer code and shows a list of files are pulled from server

[B] Master 有更新的代码并显示从服务器拉取的文件列表

$ git checkout your_branch  Note: make sure you are working in your branch
$ git rebase master

Now you will get a message about conflicts so start working on each file from bottom to resolve conflict now add that file

现在您将收到有关冲突的消息,因此从底部开始处理每个文件以解决冲突,现在添加该文件

$ git add <filename which you just updated> 
$ git rebase --continue

Follow above two commands until all conflicts are resolved. Now master changed are merged into your branch and pushed to server << YOUR BRANCH Now you need to update master branch

遵循以上两个命令,直到解决所有冲突。现在主更改合并到您的分支并推送到服务器<<您的分支现在您需要更新主分支

$ git checkout master
$ git merge <YOUR_BRANCH>
$ git push

Verify NOTE: When rebasing if your current changes are overwritten and you dont want to continue, run -

验证注意:如果您当前的更改被覆盖并且您不想继续,则在重新设置基础时,运行 -

$git rebase --abort

While doing merge/rebase if a message windows appear to write your commit statement, THERE IS NO ESCAPE... write something and then do the following-

如果消息窗口似乎在编写您的提交语句,则在进行合并/重新设置时,没有逃脱...写点东西然后执行以下操作-

$git reset --hard HEAD~1

[This command will reset the current commit head to 1 level back to what happened in the last merge will revert]

[此命令会将当前提交头重置为 1 级回到上次合并中发生的情况将恢复]

回答by Johnny

If you have trouble seeing the Git Staging view or the staging view shows the wrong repository, then just click on the triangle next to the rebase icon in your toolbar and click on abort.

如果您无法看到 Git 暂存视图或暂存视图显示错误的存储库,那么只需单击工具栏中 rebase 图标旁边的三角形,然后单击中止。

Click here

点击这里

回答by Denis S.

If you're blocked in rebase state, and if eclipse refuses to abort it (no response), you have to deactivate auto build of your project, by unchecking the following:

如果您在 rebase 状态中被阻止,并且 eclipse 拒绝中止它(无响应),则必须通过取消选中以下内容来停用项目的自动构建:

Project / Build automatically

项目/自动构建

This will stop all pending builds.

这将停止所有挂起的构建。