From the course: Git Essential Training

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Revert a commit

Revert a commit

- [Instructor] In the previous video, we looked at how to view past versions of our project. Now, let's see how we can actually take back the changes in the previous version. Maybe we introduced a mistake or a bug that we need to undo. We can quickly fix that with git. First, let's check our commit history. I'll use git log --oneline. Now, let's say I want to undo the change where I renamed GitStatus.demo. To do this, I'll copy the commit ID and I'll use git revert and then copy and paste. When I press Enter, Git opens an editor message where I can modify the commit message for the fact that I have reverted. I like this message as it is, so when I close the editor, the commit is done. Now if I check my files on the left, I see that my file has been named back to gitStatusDemo.md. Now, it is important to note I am not actually rewriting history. That's generally considered bad practice because it can cause issues if others are working on the same code. Instead, what I have done is…

Contents