Using git, how do you reset the working tree (local file system state) to the state of the index ("staged" files)?
git
Solution
I tend to use `git checkout .` which discards all changes from the working directory down. This makes a difference if you're not at the root of the repository.
This command doesn't remove newly created files which is usually a good thing. If you need to do this then you can use `git clean` as well.
Problem
Situation: - Edit files - Add files to the index with `git add` (these files are now "staged") - Edit more files Now we have three different states: the state of `HEAD` (which points to the last commit), the state of the index (which includes all added, or "staged" files) and the state of the working tree (the unstaged, local file system state). What is the command to undo changes in the working tree so that it matches the state of the index?