I have successfully used only these two commands below when I make several changes to a branch and wish to get rid of them all without having committed anything yet.
The first command is to reverse all changes in files that were versioned:
git checkout -- .
The according to is to delete all files and directories created:
git clean -f -d
At the last command, you can still add the -x to also delete files that were created but are being ignored by git (therefore, they do not appear in git status).
If you have added files in index (using git add), you need to apply the following command before the above commands, to remove them from index:
git reset HEAD .
You can also use: git checkout filename
– Leandro Macedo
This would only work for files that have changed but haven’t been committed yet
– Vinicius Cainelli
It’s what’s being asked, not commited files
– res
Whoops, that’s right, whatever’s not committed.
git checkout .reverts: changed, added and deleted files that have not been contemplated by a commit?– Fábio Jânio
That’s right, basically undoes the design changes
– res