How to undo last commit

Git

Git Problem Overview


I did the following comments

git add /file1/path
git rm /file/path
git commit -m "message"

how do I undo my last commit using git?

Like I don't want to have those files committed.

Git Solutions


Solution 1 - Git

Warning: Don't do this if you've already pushed

You want to do:

git reset HEAD~

If you don't want the changes and blow everything away:

git reset --hard HEAD~

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKermit the FrogView Question on Stackoverflow
Solution 1 - GitmanojldsView Answer on Stackoverflow