If you've committed some files in your local repository by mistake, you can undo it without losing your changes using the below command
1)Don't remove staged files
git reset --soft HEAD^
2)Remove staged files
git reset HEAD^
If you want to undo commit and lose all the changes, you can use
git reset --hard HEAD^
Top comments (3)
These commands made my day lol
Glad that helped!
If you can edit the hashtags of this posts it would be awesome and in more detail about the commands so beginners will love it too.