Sometimes you recognize after committing some changes a bug or a failure that you introduced with your commit. In those cases, you usually fix the problem by fixing the problem in a second commit. Git allows you to restore your commits, so you don’t have to mess up your commit log.
After committing, at first you use the following command to figure out the hash of the commit that you would like to revert (usually the commit before your faulty commit):
Now you use the following command with the hash in sharpen brackets to revert to the previous commit:
After this procedure the faulty commit is not recognized anymore by your Git repository and you can continue working on your project.