'How to unmerge a previously merged commit in git?
Initially I had this:
> git log --oneline
a807e4a (HEAD -> master) Add test
.
.
.
4a92648 Improve xyz file
f81cae4 Edit xyz file
.
.
.
7cbf3ec Add gitignore
Then I was playing with git, and did some rebases. Now when I log, I get this:
> git log --oneline
547748a (HEAD -> master) Add test
.
.
.
ed9f256 Edit xyz file
.
.
.
7cbf3ec Add gitignore
As you can see, one commit there has been merged with the commit below it, accidentally. It went unnoticed, and I'm noticing it now. When I refloged, I was able to find the missing commit's hash (I guess its correct). But I don't know how to restore it.
If I do git reset --merge 4a92648
then it would go to that commit, but I lose the changes I did after that! Can someone help me to get back that commit without losing the changes I made after that. Note that, these changes are only in my local machine and I haven't pushed them yet.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|