Git · Junior · Question 28 of 75
How do you discard uncommitted changes to one file?
- 1
git rm --force file.js - 2
git revert file.js - ✓Correct answer:
git restore file.js
Explanation
git restore (or the older git checkout -- file) replaces the working copy with the version from the index. The discarded changes can't be recovered by Git.