oops! how to undo `git pull`

Today I did git pull when I really wanted to git merge --no-ff. Uh-oh. Luckily for me the fix was pretty easy. I just did git reset --hard and it worked out well because I hadn’t done any work since the last push. That meant the local and remote branches were pretty close, so I wasn’t undoing any work.

Just in case you do have more local commits that you want to save you can use git reflog to find the hash of the commit you want to revert to. Then you can run git reset --hard <whatever hash you selected above> And voila! You are back in business.

I found lots of info on this online, but this site was the simplest explanation of things for me.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.