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

You may find that you need to undo several recent commits in your repository. You can do so using the following command:

$ git reset --hard HEAD~3
HEAD is now at d240853 Initial commit

Where ~3 represents the number of commits you wish to undo. You'll then see that the HEAD of your repository is now at the commit before the ones you've now undone.