# This will destroy any local modifications.
# Don't do it if you have uncommitted work you want to keep.
git reset --hard 0d1d7fc32
# Alternatively, if there's work to keep:
git stash
git reset --hard 0d1d7fc32
git stash pop
# This saves the modifications, then reapplies that patch after resetting.
# You could get merge conflicts, if you've modified things which were
# changed since the commit you reset to.
git log
commit 101: bad commit # Latest commit. This would be called 'HEAD'.
commit 100: good commit # Second to last commit. This is the one we want.
To restore everything back to the way it was prior to the last commit, we need to reset to the commit before HEAD:
git reset --soft HEAD^ # Use --soft if you want to keep your changes
git reset --hard HEAD^ # Use --hard if you don't care about keeping the changes you made
# as the best wat to revert back 3 commits
git revert HEAD~3
git restore #to restore files from commit
git checkout . #This will get rid of all uncommited change
git reset --hard branch_name #Reverts all modified files to last commit on branch
git checkout 12feg3435 #commit ID
# Revert is the command to rollback the commits.
git revert 2h3h23233
# push after change
git push
# Go back to the selected commit on your local environment
# Don't forget the . in the end
git checkout <commit-id> .
# Add this version to the staging area and push to remote
git add .
git commit -m "Reverting to <commit-id>"
git push
git commit --amend #will add the changes to the prev commit