git restore file.txt # discard changes in working dir (like git checkout -- file)
git restore . # discard ALL working dir changes
git restore --staged file.txt # unstage a file (keep changes in working dir)
git restore --staged . # unstage everything
Warning: git restore on the working directory is permanent — the changes are gone, not just staged or committed. Only use it when you're sure.
git status # see what's changed
git diff # review the changes
# Option A: keep the changes (stage them)
git add file.txt
# Option B: throw them away
git restore file.txt
important.txt has been accidentally overwritten. Use git restore to bring it back to its last committed state. Also, unstage draft.txt without deleting it.
Click "Run" to execute your code.