You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Undoing Local Changes That Have Not Been Committed
$ git status # List affected files
$ git checkout filename.html
# File has now been reverted to previous commit
Undoing a Specific Commit (That Has Been Pushed)
$ git status # Make sure you have a clean working tree
$ git log --oneline # Find your commit's unique hash
$ git revert <hash> --no-edit
$ git push
# This will make a new commit and will revert the file(s) to their previous state as if it was never changed.
Undoing Your Last Commit (That Has Not Been Pushed)
$ git reset --soft HEAD~ # Revert last commit
OR
$ git reset --soft HEAD~2 # Revert last 2 commit (You can change number)
Undoing Local Changes That Have Been Committed (But Not Pushed)
$ git status # Make sure you have a clean working tree
$ git log --oneline # The one you want to revert back to
$ git reset <hash>
$ git reset --hard <hash># If you do git reset the commits will be removed, but the changes will appear as uncommitted, giving you access to the code. # If you dogit reset --hard the commits will be removed and the changes will disappear.
This is very useful content. Thanks!