Pages

Friday, December 14, 2018

How to undo a git cherry-pick successfully?

How to undo a git cherry-pick successfully?

I was working in a repo and was required to have  changes of someone into my code. Hence git cherry-pick is the choice for this. But lately I found I took a wrong commit. How to undo a git cherry-pick successfully ? This was my requirement. But two options exists.

What if I have local Changes,

$ git stash
$ git reset --hard HEAD^
$ git stash pop  # or `git stash apply`, if you want to keep the changeset in the stash


What if I dont have local Changes ?

$ git reset --hard HEAD^


Reference:
https://stackoverflow.com/questions/30986376/how-to-undo-a-successful-git-cherry-pick

No comments:

Post a Comment