Git discard local changes
up:: Git
Discard a file
git checkout @ -- file
@
is an alias for HEAD
For the whole branch
git fetch --all
git branch backup-main # optional
git reset --hard origin/main
Discard last commit, keep changes
git reset --soft HEAD~1