Sometimes, when working with git, you end up attempting to undo local changes or reset a git branch to the remote. Here's a mini-guide to accomplish that.
We'll begin with the following assumptions: you have a user branch that is tracking a remote/upstream, you have local edits that you want to discard and you want to reset local to the latest remote/upstream commit.
Confirm local changes
Make sure you know what changes you're about to lose. If you want to preserve anything for later, you can use
Alternative: Clear files
Consider whether you can use a simple method to remove untracked files instead of reseting the branch. You can try git clean or checkout:
git clean -f
Remove all untracked files.
git checkout .
Remove all unstaged changes in my working tree.
Reset to the latest commit on remote / upstream
This will remove all local changes.
git reset --hard HEAD
The result is the same as re-cloning the repository.