Discard the changes of a file
Description: You edited config.txt and broke it. Discard your edit and get the last saved version back.
Hint:
- Use
git restore file. It cannot be undone, so be sure.
Solution
Terminal output
$ git status -s
M config.txt
$ git restore config.txt
$ git status -s
$ cat config.txt
theme=light
How it works
- The file is replaced with the version from the last commit.
- Changes that were never committed are lost, Git cannot bring them back.
Read Git Restore.
Learn more about the similar topics:
| Tutorials |
|---|
| No Content Found. |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |