Undo unsaved changes in Git
If you did a git checkout on a branch and found conflicts or, in general, you did some changes in your local repo, you can undo everything and go back to the previous state with these steps:
git reset --hard HEADThis command reverts everything to the state of the last commit and discards local changes, including conflicting ones.
or better
git reset --hard origin/nome-del-branchIf there are any untracked files that are causing problems, you can delete them with:
git clean -dfJust a tricky, if you want to go back to the previous branch, just do this:
git checkout -