Little Git Tricks: Get Rid of Commits
If we committed something into a Git repository that should not be there, we could rewrite the history and make it look as it was never there.
I usually try to prevent rewriting the history, especially when I already pushed the changes. Then when we modify the past, everyone in the team needs to do some extra work to catch up.
If this is not a problem or the lesser evil, we can use the following steps to rewrite the Git history.