When you modify files, then they go to modified state which you can confirm by running
$git status On branch master Changes not staged for commit: (use "git add
..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory) modified: sales.csv modified: order.csv no changes added to commit (use "git add" and/or "git commit -a")
Here, you can see that
order.csv files are modified.
You can even view the difference between the modified files and the last commit by running
git diff command.
To discard the changes, you have to run
git checkout command:
$git checkout -- sales.csv $git checkout -- order.csv
You have to replace
order.csv with filenames that you want to undo.
Note: If you want to unstage files, then visit this page: How to remove files from staging?
The process of discarding changes can be understood with the help of the below image: