xxxxxxxxxx
#move head back to the specified commit but retain changes made since
#allows to force push to remote if commits were pushed in error
#but work can continue without starting over
git reset abc1234
#move the head back and remove all trace of changes since specified commit
git rset abc1234 --hard
#after either you can force push to the branch so the remote is aware of the rollback
git push -f
xxxxxxxxxx
$ git reset --hard HEAD (going back to HEAD)
$ git reset --hard HEAD^ (going back to the commit before HEAD)
$ git reset --hard HEAD~1 (equivalent to "^")
$ git reset --hard HEAD~2 (going back two commits before HEAD)
xxxxxxxxxx
$ git reset --hard HEAD (going back to HEAD)
$ git reset --hard HEAD^ (going back to the commit before HEAD)
$ git reset --hard HEAD~1 (equivalent to "^")
$ git reset --hard HEAD~2 (going back two commits before HEAD)
xxxxxxxxxx
You can restore with this
>> git reflog #Lists the actions, including reference to deleted commit
#You can now find the id of the deleted commit and easily restore it like this
>> git reset (deleted commit id) --hard
#eg. git reset "8c7a2a0" --hard
xxxxxxxxxx
git reset --hard f414f31
git reset --soft HEAD@{1}
git commit -m "Reverting to the state of the project at f414f31"
xxxxxxxxxx
git reflog
see all heads
git reset --hard HEAD~0
will go to latest commit.
git reset --hard HEAD~1
will go to last but one commit.