Egit - Cannot checkout now - stuck in rebase state

22,778

Solution 1

In Git Staging view there is an option to abort rebase.

enter image description here

Solution 2

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.

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

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

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

git merge <your branch name>
git push

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

$ 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]

Share:
22,778

Related videos on Youtube

Cydhra
Author by

Cydhra

Updated on July 21, 2022

Comments

  • Cydhra
    Cydhra almost 2 years

    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":

    Rebase w/merge state of the project

    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).

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

    I tried:

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

    That is the error notification.

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

    Git Repo View

    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.

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

  • Cydhra
    Cydhra over 8 years
    Thanks! That was the option I searched for. It is a little bit odd that I always have to abort the rebase, that I did not initiate, but aborting has no impact on the server files, as I noticed, so after merging, I simply abort and everything's fine. TY!
  • Michał Grzejszczak
    Michał Grzejszczak over 8 years
    You can also click continue. EGit will then mark rebase as done I think.
  • andrefilipeos
    andrefilipeos over 4 years
    THANKS! helped me