To revert a commit in Git, you can use the following command:
git revert <commit-hash>
This action will create a new commit that undoes the changes made in the specified commit, effectively rolling back your project to its state before that commit. You’ll need to know the commit hash of the commit you want to revert. You can find this hash by using the git log
command, which shows the history of your commits along with their corresponding hashes. Once you have the hash, replace <commit-hash>
with the actual hash of the commit you wish to revert.
This will open an editor for you to enter a commit message for the revert. After saving and closing the editor, your repository will include a new commit that negates the changes of the specified commit.