Reputation: 7314
I created and switched to a new branch and made some changes that haven't been commited. How do I return to the state of my last commit? I used
git reset --hard HEAD
but all the changed files are still present
edit; after running the above and then git status it says "nothing added to commit but untracked files present". I thought using git reset...would get rid of all the changes
Upvotes: 1
Views: 2922
Reputation: 13526
There are 2 ways work for me:
git clean
git reset --hard HEAD #reset all
or
git checkout file_I_want_discard_my_change
Upvotes: 0
Reputation: 11628
git clean
removes all files (recursively) that are not under version control, starting from the current directory.
See the git clean docs for more info
Upvotes: 4