0

I have changed and added a couple of files within my project for test purposes and now I am trying to reset the entire project to last commit I did. Hence, I want to reset to HEAD. So I did:

git reset --hard HEAD

So now, all the files I changed are reset to the version I had at my last commit, but the problem is, that all the new files I created still remain. Shouldn't in reset process all be reset to exactly the version of in this case HEAD?

How can I properly set everything in my project to the state of the HEAD as if I didn't change anything?

Socrates
  • 8,724
  • 25
  • 66
  • 113
  • 2
    Did you research this at all? I found https://stackoverflow.com/questions/4327708/git-reset-hard-head-leaves-untracked-files-behind more or less immediately – jonrsharpe Apr 16 '18 at 14:26

1 Answers1

3

To remove any untracked files, run

git clean -df

(-d removes directories, -f means "force" - without it, nothing is removed.)

You can also add -x to remove ignored files (see git help clean).

choroba
  • 231,213
  • 25
  • 204
  • 289