This post will briefly explain the process of reverting modification in Git using the “git revert” command.
How to Revert Modification in Git Using the “git revert” Command?
To revert modification in Git using the “git revert” command, do follow the below-stated procedure:
- Move toward the Git local repository.
- Execute the “git log –online” command to view each commit in a single line.
- Next, revert a commit with the help of “git revert” along with the SHA hash of a specific commit.
- Modify the message to revert and save changes.
Step 1: Navigate to Local Repository
First, execute the “cd” Git command along with the path of the specific local repository and move to it:
Step 2: View Git Log
Next, view the Git log of each commit in a single line by utilizing the “git log –online” command:
From the below-stated output, we have selected the SHA hash of a specific commit for further use:
Step 3: Revert a Commit
Lastly, run the “git revert” command along with the selected SHA hash of the particular commit to revert the changes:
As a result, the default editor has been opened on the screen:
Modify the revert message, press “CTRL + S” to save the changes, and close the editor:
According to the following output, the changes have been reverted successfully:
That’s all about revert modification in Git using the “git revert” command.
Conclusion
To revert modification in Git using the “git revert” command, first, move toward the Git local repository and run the “git log –online” command to view each commit in a single line. Then, select a particular commit and execute the “git revert” along with the SHA hash of a specific commit. Lastly, modify the message for reverting in the default editor and save the changes. This blog explained the method to revert modification in Git using the “git revert” command.