Undo changes in working copy or index
suggest changeUndo changes to a file or directory in the working copy.
git checkout -- file.txt
Used over all file paths, recursively from the current directory, it will undo all changes in the working copy.
git checkout -- .
To only undo parts of the changes use --patch. You will be asked, for each change, if it should be undone or not.
git checkout --patch -- dir
To unstage changes, use a mixed reset (the default). This clears them from the index and leaves the working tree as it is.
git reset
git reset --hard (with no path) also throws away uncommitted working-tree changes and matches HEAD. It is not a soft reset. git reset --soft moves HEAD and leaves both the index and the working tree alone.
With local commits that you have yet to push to a remote you can also do a soft reset. You can thus rework the files and then the commits.
git reset HEAD~2
The above example would unwind your last two commits and return the files to your working copy. You could then make further changes and new commits.
Beware: All of these operations, apart from soft resets, will permanently delete your changes. For a safer option, use git stash -p or git stash, respectively. You can later undo with stash pop or delete forever with stash drop.