This can be done, but I would prefer not to. Changing the past has side effects. The branch or commit tree will not be redirected forward, and you will have to redefine the branch on the server, if any. In other words, if you are not the last one to see him, and this is only on your computer. This can create more problems, and you risk losing things if something goes wrong.
If you are ready to enter the world of time travel and alternative reality!
Welcome to git rebase
First, create a new branch in which you want to reinstall, this will create a copy of the branch you want to change, in case something goes wrong, just delete rebase and nothing will change. You can simply mark the commit hash.
The easiest way to get started with git rebase -i HEAD~N , where N is the number of commits in the past that you want to change.
It should open an editor, you can change the first word of each line to something like editing. Then save the file and you will be rebooted!
When rebooting, you can do anything you like, add files, delete files, etc. When you commit, if there is no conflict, it should automatically continue. And as soon as everything is done, you will have a restored branch with a commit, or a deleted, edited, renamed one, and that's all you wanted. Then if everything is correct. Delete the old branch (do not reinstall) Click on the new branch with the buffer and voila.
Edit
If this is not very clear when he opens the editor. When you delete a row, the selected commit is deleted. If you delete everything in the file, it will not do anything. You can abort it at any time during the reboot, and the state of the git project should not change. Rebasing is a completely safe thing, because it does not change anything. If you keep links to old commits, they will not disappear. After a reboot, it creates an alternate path. You will have one old path and a new path. The old path can be dereferenced, and all references to this old path must be redirected to the new path.
Attention!
By the way, one thing I would do instead is to simply commit to something that captures the old commit. I believe that rebooting should be used only when necessary. For example, when your colleague accidentally backed up a 4gb database.