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.

Undo your changes

Undo your changes

- [Instructor] As we make changes to our files, there might be times where we don't want to keep them. Maybe we realize we need to go back to the previous commit, and the good news is we can do that with Git. Let's see how it works. To start off, I've removed a line from NewName.md and I've added a line to newStatus.md. I will now stage those changes by using git add ., and I'll use git status and see that both of the files are in the staging area. But what if I change my mind at this point? What if I don't want to commit these changes after all and I want to do a rollback? The good thing is git status actually tells me what to do. It suggests using git restore --staged, followed by the file name to remove it from staging. Let's try that with NewName.md. We'll type git restore --staged First_Folder/NewName.md. Note that the folder is part of the file name here. I'll press Enter. And when I check git status, one file is still in the staging area, but NewName.md has moved back to the…

Contents