1

Is there a way to disregard the changes made after my attempt to rebase and go back to the latest code I have pushed into main remote repository? Rebase left all the conflictinh classes with errors after it stacked two different versions into one class.

I made my latest changes in Eclipse and pushed them successfully into the main branch. When I was trying to submit a merge request I was asked to rebase due to a number of conflicting files. In the process of rebasing in Eclipse I had to compare versions of classes with a number of commits. I am new to working with Eclipse so I wasn’t sure how to “pick” my local changes instead of the ones from the earlier commits. Because of this issue git put together both versions into one class which was too we convoluted for me to sort through. I am now left with 5 classes that are have a bunch of errors and it would be easier if I could just pull the code that I had successfully pushed to start fresh.

What is the easiest way to do this without running into the same issue?

howlger
  • 31,050
  • 11
  • 59
  • 99
  • Does this answer your question? [How do I reset the git master branch to the upstream branch in a forked repository?](https://stackoverflow.com/questions/42332769/how-do-i-reset-the-git-master-branch-to-the-upstream-branch-in-a-forked-reposito). The answers there show ways to reset to the upstream master, but they do so using the console, not the eclipse integration. – Hulk Aug 22 '23 at 06:23
  • See https://help.eclipse.org/latest/topic/org.eclipse.egit.doc/help/EGit/User_Guide/Tasks.html#Resetting_your_current_HEAD – howlger Aug 22 '23 at 07:03
  • @Hulk This question is not about the command line Git. – howlger Aug 22 '23 at 07:03

1 Answers1

0

If you're using Eclipse with EGit:

  1. Open the Eclipse IDE: Launch the Eclipse IDE and navigate to the project you're working on.

  2. Open the History View: Right-click on your project in the Package Explorer or Project Explorer and select Team > Show in History.

  3. Locate the Commit You Want to Revert To: In the History view, locate the commit where you successfully pushed your changes. You can search for it or manually browse through the commit history.

  4. Revert to the Desired Commit: Once you've found the commit, right-click on it and select Checkout.... This will set your working directory to the state of that commit.

  5. Create a New Commit: After reverting to the desired commit, you'll have unstaged changes in your working directory. Review the changes in your project and commit the changes to create a new commit.

  6. Push the Reverted Changes: Right-click on your project again, select Team > Push Branch..., and follow the prompts to push the changes back to the remote repository. Since you've created a new commit, you won't need to use force pushing in this case.

if you are working with a team then it would be a good idea to inform them

Shila Mosammami
  • 999
  • 6
  • 20
  • The question is about how to do this in Eclipse, not on the command line. On the command line Git might not even available. See https://help.eclipse.org/latest/topic/org.eclipse.egit.doc/help/EGit/User_Guide/Tasks.html#Resetting_your_current_HEAD – howlger Aug 22 '23 at 08:12
  • @howlger my bad, I am going to edit my response, I hope it helps you – Shila Mosammami Aug 22 '23 at 08:15
  • 1
    Thanks for the edit. You answered at least five questions today and the answers sound AI generated. Could you please tell me if you wrote the answers on your own or with the help of AI and if so, with which AI? – howlger Aug 22 '23 at 09:05
  • @howlger Do you think answering 5 questions within at least 90 mins I spent to answer is a lot? I might check the grammar but not the response. I have used stackoverflow to resolve my own problems and when I have time I would go and filter questions based on what is interested for me to respond IF I have any idea. If my response resolved your problem then please consider it as accepted or even nothing and vice versa if I am responding completely wrong then consider a downgrade. – Shila Mosammami Aug 22 '23 at 09:22
  • Yes, that's a lot. Don't get me wrong, the use of generative AI is not banned anymore. Just make sure that the given answer is correct. I'm just curious about how to use generative AI efficiently and which tools exactly are best to use. Regarding your answer: I think the question is about local changes that do not affect the team and a force push of a branch is not the right thing to do, otherwise trying to rebase in the first place would not make sense. – howlger Aug 22 '23 at 11:24
  • Dear @howlger, I do not think it is a good idea to post AI responses here since everyone has the access I guess, I do not know in stackoverflow is permitted or not but if it was on my hand, I would suggest ppl not to do so. anyway, there are ai tools like bing chat, bard of google and etc. Finally, I prefer to wait for him to emphasise what he wants or if I am making mistakes on what he meant – Shila Mosammami Aug 22 '23 at 11:44