Search code examples
gitversion-controlgit-commit

How do I delete last local commit in Git?


I accidentally committed the wrong files to Git, but I haven't pushed the commit to the server yet.

How can I delete that commit from the local repository?


Solution

  • Try git-reset https://git-scm.com/docs/git-reset you can reset your state to a previous commit keeping your changes. Something like this should work git reset --soft origin/master