What command reverts a specific commit?
Posted by DavidLee
Last Updated: July 07, 2024
To revert a specific commit in Git, you can use the git revert command followed by the commit hash of the commit you want to revert. The command is structured as follows:
git revert <commit-hash>
Replace <commit-hash> with the actual hash of the commit you want to revert. This command will create a new commit that undoes the changes made in the specified commit while preserving the history. For example, if the commit hash is abc1234, you would run:
git revert abc1234
After executing this command, Git will create a new commit that negates the changes from abc1234. If there are conflicts during the revert, you will need to resolve them before you can complete the revert operation.