How do you discard changes in one file?
BeginnerConceptUndoing changes: reset, revert, restore and reflog
Answer
Restore it from the index or a commit. This permanently discards the uncommitted edits since they were never stored.
git restore app.py
git restore --staged app.py # unstage only
git restore --source=origin/main app.py # take main's version
More on Undoing changes: reset, revert, restore and reflog
What are the three modes of `git reset`?BeginnerWhat is the difference between `git reset` and `git revert`?BeginnerHow do you recover a commit after `git reset --hard`?IntermediateCan you recover uncommitted changes lost by `git reset --hard` or `git checkout .`?IntermediateWhat does `git commit --amend` do to the reflog and to the old commit?IntermediateHow do you undo `git add` for a file?Beginner