I have tried a lot of ways to revert local changes in Git, and it seems that this works the best if you just want to revert to the latest commit state.
git add . && git checkout master -f
Short description:
git revert
does.git checkout <commithashcode>
does.I found a much more convenient and simple way to achieve the results above:
git add . && git reset --hard HEAD
where HEAD points to the latest commit at you current branch.
It is the same code code as boulder_ruby suggested, but I have added git add .
before git reset --hard HEAD
to erase all new files created since the last commit since this is what most people expect I believe when reverting to the latest commit.