Git Reset to Previous Commit
Find The Commit
Log all commit history
git log
Then copy the previous hash commit you want to reset to it, commit <hash>
.
Hard Reset
Once you have the hash, do hard reset
git reset --hard <hash>
Example:
git reset --hard 7e9c66afa4e45a3cc0bc6d56e67e0faea7aa3b72
Update: Use
–soft
instead–hard
so you can get the staged changes :)
Example:
git reset --soft 7e9c66afa4e45a3cc0bc6d56e67e0faea7aa3b72
Push it
Then force push to remote branch
git push -f <remote> <branch>
Example:
git push -f origin master