This is probably a simple (but irritating) question. How do you remove all changes remove changes since last commit? I botched a patch, and I want to go back to how things were at my last commit.
I have tried:
git reset --hard master
and
git checkout master
but neither rid my folders of the files hat I have added / changed (they are still listed as untracked files.)
Untracked files are just that, untracked. Git doesn't know or care about them. git reset --hard will only revert tracked files to the state they were in at the most recent (or named) commit.
You can use git clean to remove untracked files and directories from your working tree. Be careful you don't accidentally delete any hard work!
The "silver bullet" that will restore a repository back to the state it was at as of the most recent commit, as if you had just cloned it (this will even remove all user files that are "ignored" by the repository!) would be this: git reset --hard && git clean -fdx. (If you omit the x flag then it will only remove untracked files that are not ignored, which might include build products, for example.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With