1

I want my entire repository to roll back to a certain previous commit (that is 20 commits behind my latest commit).

I tried using git reset --hard <commit#> and git revert <commit#>

Both the git commands run successfully with the message - Head is now at <commithead>

But then when I see the code in my repo, I can still see the edits I made in my latest commits. How can I remove all the edits after the particular commit I am reverting to?

Am I missing out on some step here?

1 Answers1

1

After your git reset --hard, use to be sure the git restore command

cd /path/to/repository
git restore -- .

That should restore (as its name implies) the working tree with what is in HEAD (and you just reset HEAD to the right commit)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250