Reset repository back to initial state

For testing, I often want to reset my local repository back to its initial state, as if I had git clone’d a fresh copy from Codeberg. To do this, I’ve been performing these steps, from the repository top-level directory:

$ rm .gitignore
$ git clean -f -d
$ git restore .

I’m not sure if any other steps might be needed? For example, I’m not sure if performing npm cache clean --force might also be a best practice?

Can’t you just make a new branch from whichever branch you want to test with, and just delete it afterwards?

Yes, I can just clone a fresh, new local repository into a different directory. And, I do do this when I really want to 100% ensure that I am getting the initial state experience.

However, most of the time I don’t want the overhead of spending bandwith, (temporary) storage space, and time to clone a new copy. That is why I would rather just revert/reset my existing repository, if it is possible to do so.

Creating a new branch hardly takes any bandwidth if I’m not mistaken. Creating a new fork would.

Oh, I see what you are suggesting.

No, simply creating a new branch would not achieve the goal because all of the (possibly stale) prebuild-created files and node_modules would still exist in the repository. And, I am not confident that npm run kickstart is enough to replace/overwrite all of them.

Ah, I see what you’re trying to accomplish. In that case, I’m of no use. My knowledge of git is not adequate enough to advice you here. I would just create a new fork, since I’m lazy.