Reputation: 2299
I'm in the middle of one big rebase with a lot of conflict.
just found out a couple of git rebase --continue
before actual I accidentally delete one file instead of another.
How can I go back in pacth and fix this, and then reapply the patch?
Edit: --abort
is not a solution as I will have to do ALL the patch again. I want to abort only part of them
Upvotes: 3
Views: 1566
Reputation: 60393
Everything in your repo stays there until git sees it's been wholly unreachable, through any ref, for at least a month1.
So you've done some equivalent of git rebase master topic
, with say 26 commits A-Z on topic since the branch, and you did what turns out to be a really bad oops rebasing O and didn't really get the full effect until S:
A...O...Z topic
/
...b....* master
\
A2..O2..S2 the inflight rebase with the mistake in the rebased O, O2
Your backout is
git tag restart O2~
git rebase --abort
git rebase --onto restart O^ topic
and now you only have to redo the commits infected by the oops.
If there are good parts to the commits in the O2~..S2 series, conflict resolutions you want to retrieve, you can tag S2 as well, and then during your redo just check out the good parts from those commits, git checkout -p boneyard~3 -- goodpart1 goodpart2 etc etc
(where you've tagged S2 as "boneyard" and the good parts are in P2)
I've done this, hosed a rebase and had to redo it. I wouldn't be surprised if everyone's done that at one point or another. It's no big deal, even for seemingly horrendous cases like yours.
1You can force the truncation earlier. Don't Do That.
Upvotes: 7
Reputation: 47876
Do the following:
git rebase --abort
This will abort the rebase and bring your HEAD
back to the state it was before the rebase.
I don't think there is an option to revert a single patch using git rebase
. See the possible options in git rebase docs.
git rebase --help
GIT-REBASE(1) Git Manual GIT-REBASE(1) NAME git-rebase - Forward-port local commits to the updated upstream head SYNOPSIS git rebase [-i | --interactive] [options] [--onto <newbase>] [<upstream>] [<branch>] git rebase [-i | --interactive] [options] --onto <newbase> --root [<branch>] git rebase --continue | --skip | --abort In case of conflict, git rebase will stop at the first problematic commit and leave conflict markers in the tree. You can use git diff to locate the markers (<<<<<<) and make edits to resolve the conflict. For each file you edit, you need to tell git that the conflict has been resolved, typically this would be done with git add <filename> After resolving the conflict manually and updating the index with the desired resolution, you can continue the rebasing process with git rebase --continue Alternatively, you can undo the git rebase with git rebase --abort
Also check this link if it helps.
http://arigrant.com/blog/2014/5/4/git-rebase-stepping-forward-and-back
Upvotes: 1