Forgot "git rebase --continue" and did "git commit". How to fix?
I was rebasing code in git, I got some merge conflicts. I resolved the conflicts and did:
git add
At this point I forgot to do:
git rebase --continue
I continued coding and did:
git commit
for the changes. Now I am on "no branch"
and can't do:
git rebase --continue
How do I fix this?
Just do git reset --soft HEAD^
. It moves the HEAD pointer to its parent but keeps the work tree and adds the merge change to the index. So you can continue rebasing with git rebase --continue
as before.
EDIT: Look at the answer below as well to see if that's an easier solution for you. https://stackoverflow.com/a/12163247/493106
I'd have to try it out, but I think this is what I would do:
- Tag your latest commit (or just write down its SHA1 somewhere so you don't lose it):
git tag temp
git rebase --abort
- Do the rebase again. You'll have to resolve the merge again. :(
git rebase --continue
git cherry-pick temp
The problem with this is that your temp
commit probably contains both the resolution of the merge, and the new code. So it could be tricky but I would try it and see if it works.