How to completely replace local working directory with remote main?

I successfully managed to push my first commit to the newly created Github repo, and it has code that worked when I commited/pushed it.
Since then, I’ve made changes and now it’s not running anymore.
I tried to revert all the local changes with git reset --hard origin/main, but it’s still not running. I’m guessing this did not replace all the contents of the working directory, because it’s an Angular project and it also contains lots of Node modules that I excluded in .gitignore - i.e. my next step would be to erase the directory completely including all installed libraries and start fresh with the working code pulled from remote.
My question is about that second part: How do I pull from remote to my local directory and make sure Git versioning does not get messed up? Should I keep the .gitignore file (see below) before deleting everything?
Or maybe this question is to specific, let me rephrase:
What’s the best way to start over without having to reset the remote repo?
Btw I also have a local working copy of the code in a different directory.

Are you just looking for git clone? If you just wanted a copy of the remote repo and it’s history than that’s the way to go.

If you have important changes in your local repo that you don’t want to lose then consider setting your current local repo up as it’s own branch before resetting anything so that you can test your additions/alterations bit by bit (with lots of ignored files this could be harder). Something like git clean could be used to try and clear up any untracked local files (flags needed to catch ignored files/dirs) but unless you’re backing things up this might not be the best option. Make sure you have it backed up somehow if it’s important.