I'm using git svn to get some git goodness with the company-mandated svn server. I just had a rebase go horribly awry, and I"m trying to figure out the best way to recover.
Here's what happened:
To start with, I had this
---1 (master) \--B--C--D--E (feature/fix-widgets) So then I did git checkout master and then git svn rebase on master to pull down those commits. I did not anticipate any conflicts between my feature branch and the master, because the changes were in a totally different folder. So at this point, I think I have this:
---1--2--3--4 (master) \--B--C--D--E (feature/fix-widgets) Where 1--2--3--4 are commits pulled in from svn.
Next I do git checkout feature/fix-widgets and then git rebase master. There's immediately a conflict, and some things that don't add up, so I decide to slink away and look at things more carefully. I do git rebase --abort, hoping this will restore me to where I was before the rebase.
I do git rebase --abort and receive the following message
$ git rebase --abort error: git checkout-index: unable to create file somedir/somefile.cs (Permission denied) fatal: Could not reset index file to revision 'be44daa05be39f6dd0d602486a598b63b6bd2af7'. Now I'm not sure what to do. git status shows that I'm on feature/fix-widgets, but I have a whole bunch of staged changed, and a large number of untracked files, which were previously committed. I'd be fine if I could get back E.
Yes, you can rebase more than once. After rebasing, you get a fresh set of commits.
If you type git rebase --continue. you realize the error is because of a merge conflict that git cannot resolve by itself, and needs your help. To see what files have conflicts, type git status. Resolve the merge conflicts in your favorite editor/IDE (hint: this should start with i and end with ntelliJ)
You should have a look at ORIG_HEAD
ORIG_HEADis previous state ofHEAD, set by commands that have possibly dangerous behavior, to be easy to revert them.
It is less useful now that Git has reflog:HEAD@{1}is roughly equivalent toORIG_HEAD(HEAD@{1}is always last value ofHEAD,ORIG_HEADis last value ofHEADbefore dangerous operation)
So try this git reset to get back to before any rebase:
git reset --hard ORIG_HEAD
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With