Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Strategies for repairing a branch after a misguided rebase
Strategies for repairing a branch after a misguided rebase [message #1764882] Fri, 02 June 2017 20:18 Go to next message
David M. Karr is currently offline David M. KarrFriend
Messages: 801
Registered: July 2009
Senior Member
A week or so ago, I created a branch to work on a pull request. Today I was talking to another dev on the team to resolve a problem I was having while testing my code. He pointed out that he merged the changes I needed to master a few days ago.

So, I made sure all the changes I had were committed to my branch, then I switched to master to do a pull, then switched back to my branch and did a "rebase to master". At that point, I was confused, because several of the files I had on my branch were now gone. I guess a rebase strategy at that point was not effective.

I then went into the reflog and checked out detached my last commit on my branch, to verify that my files were still there.

At this point, I could take the "lazy" approach of recloning my repository into a new local repo, creating a new branch, copying in the files from the original repo (now in "detached" mode), and committing and pushing those changes.

However, I'd like to see if it's possible to repair this branch back to where it was, and perhaps now do a "merge" from master to my branch instead of a rebase. It seems likely that would have been a better strategy.

What can I do at this point?
Re: Strategies for repairing a branch after a misguided rebase [message #1765027 is a reply to message #1764882] Mon, 05 June 2017 19:43 Go to previous messageGo to next message
Thomas Wolf is currently offline Thomas WolfFriend
Messages: 576
Registered: August 2016
Senior Member
Reset hard of your branch to the commit before you attempted the rebase should do the trick.
Re: Strategies for repairing a branch after a misguided rebase [message #1765037 is a reply to message #1765027] Mon, 05 June 2017 22:29 Go to previous messageGo to next message
David M. Karr is currently offline David M. KarrFriend
Messages: 801
Registered: July 2009
Senior Member
To be clear, while on the branch, from the reflog view, with the particular commit I did before doing the rebase, right click and select Reset, then "Hard (HEAD, Index, and Working Tree)"? That would make that commit be HEAD of that branch? I would then be able to attempt a merge (not a rebase) from master?
Re: Strategies for repairing a branch after a misguided rebase [message #1765366 is a reply to message #1765037] Thu, 08 June 2017 19:27 Go to previous message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1268
Registered: July 2009
Senior Member
- open the reflog view and checkout the commit you are interested in
- create a new branch on HEAD
Previous Topic:Exploring merging master to pull request branch
Next Topic:Jgit thread hang issue
Goto Forum:
  


Current Time: Fri Apr 19 08:16:55 GMT 2024

Powered by FUDForum. Page generated in 0.02059 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top