Reputation: 3101
I merged a remote branch into my local repo and it created 26 local commits.
Now, I want to revert this merge, but it think that it is quite boring and error-sensitive to revert the commits 1 by 1 or seek for the last commit of the remote version to revert to it.
I went through the post How to undo last commit(s) in Git? which is very interesting with its answers, but I didn't found any simple way to do my local revert.
Can anybody help ?
Upvotes: 0
Views: 961
Reputation: 3101
I tried one or two things and this one is a little bit dirty, but it is simple and seems to work :
git checkout -b tempo
git branch -D dirty_one
git checkout -b dirty_one origin/dirty_one
and that's all.
The dirty thing I think is that the bad local commits are still in the local repo, but the branch don't know them so they may remain hidden.
If I redo my merge (which I have done in fact), the merge just work well, but I don't know exactly how (that the dirty part ...)
Upvotes: 0
Reputation: 4136
Use Git Log & Git Reset
git log
this will give you the commit id with message through which you can identify your commit id.
use the commit id to then reset back.
git reset <commit-id>
if you permanently want to go back to that commit. you can use the following.
git reset --hard <commit-id>
Upvotes: 2