Throw away your change and reset a git branch to remote

Sometimes, you do something really stupid and just want to get rid of it. Or you are suddenly in the middle of a complicated merge and don’t really know why anymore (“But I didn’t change anything!”). In this case, if you are sure you want to throw away everything in your local branch and just want to be at the same status as the remote branch, this is your rescue:

git reset --hard origin/<branchname>

But be careful, the --hard option deletes all changes that you have made without recovery.