Recall & Review
beginner
What does the command
git restore <file> do?It discards changes in the working directory for the specified file, restoring it to the last committed state.
Click to reveal answer
beginner
How do you discard all local changes in all files using
git restore?Use
git restore . to discard changes in all files in the current directory and its subdirectories.Click to reveal answer
intermediate
What is the difference between
git restore <file> and git checkout -- <file>?git restore is the newer, clearer command to discard changes, while git checkout -- <file> was used before for the same purpose but also has other uses.Click to reveal answer
beginner
Can
git restore undo changes that have already been committed?No,
git restore only affects uncommitted changes in the working directory. To undo commits, other commands like git revert or git reset are used.Click to reveal answer
intermediate
What happens if you run
git restore <file> on a new untracked file?Nothing happens because
git restore only works on files tracked by Git. Untracked files remain unchanged.Click to reveal answer
Which command discards changes in a tracked file and restores it to the last commit?
✗ Incorrect
git restore <file> resets the file to the last committed state, discarding local changes.
What does
git restore . do?✗ Incorrect
This command discards all local changes in the current directory and subdirectories.
Can
git restore recover deleted commits?✗ Incorrect
git restore only works on working directory changes, not commits.
What happens if you run
git restore <file> on a new file not tracked by Git?✗ Incorrect
Untracked files are not affected by git restore.
Which command was commonly used before
git restore to discard changes in a file?✗ Incorrect
git checkout -- <file> was used to discard changes before git restore was introduced.
Explain how to discard changes in a single file using Git and what happens to the file after running the command.
Think about how to undo local edits without affecting commits.
You got /3 concepts.
Describe the difference between discarding changes with
git restore and undoing commits in Git.Consider what part of the project each command changes.
You got /3 concepts.