I committed the wrong changes to Git
How do I undo those commits from the local repository?
Kuldeep Baberwal Answered question October 13, 2023
-
git reset --soft HEAD^
To keep the changes from the commit you want to undo, it will undo the commit and your changes will staged again.
-
git reset --hard HEAD^
To destroy the commit completely : this will undo the commit and changes will be discarded to the last successful commit Head
note:
if you are using Windows then use the command like this :
git reset --soft "HEAD^" where Head or commit hash should be in quotes. Original Source : Stackoverflow
Kuldeep Baberwal Changed status to publish October 13, 2023