How do I undo the most recent local commits in Git?

Git

Recently accidentally committed the wrong files to Git, but didn’t push the commit to the server yet. Then I wanted to undo those commits from the local repository, So In this article, I’m going to share with you how to do that.

Steps to undo the most recent local commits

$ git reset HEAD~                              #

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store