Git · Junior · Question 28 of 75

How do you discard uncommitted changes to one file?

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.

Further reading

Problem with a question

Git · Junior · question 28

Test yourself

Take the Git · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz