If the commit were not pushed to a remote server, you can use git rebase
to modify the git history.
You can do that:
git rebase -i commit-hash^
It will show a list of commits. The first line should be the commit you want to delete. Remove that line from the file you edited, save and close.
If you did push to a remote server prior to do that, note that the commits after the commit you just deleted were rewritten based on the commit before the one you just deleted from the history. For that particular reason, all of the commits are changed because your history just diverged. So if you try to push that, it won't be fast-forward and you'll have to force the push.
For that reason, if you're not familiar with git rebase
I suggest keeping a branch pointing to the branch you were modifying the history in case something goes wrong.
Also, if that particular commit is shared accross multiple branches, diverging the history of one branch will cause multiple problems as you won't be able to easily merge one branch from the old history to the branch in the new history. It will duplicate many commit and the commit you deleted in one branch won't be deleted in the others.
Think of it has modifying git history is like time travel. Any change at one point create a new parallel universe. Everything that was after the change in the past really is impacted by the change you did in the past.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…