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
From the course: Git Essential Training
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
-
-
-
-
-
-
-
(Locked)
Git status2m 24s
-
(Locked)
Edit a file and view changes4m 14s
-
(Locked)
Delete files1m 35s
-
(Locked)
Rename files2m 18s
-
(Locked)
Working with folders3m 5s
-
(Locked)
Undo your changes2m 20s
-
(Locked)
View commit history4m 5s
-
(Locked)
Go back in Git history1m 52s
-
(Locked)
Revert a commit1m 55s
-
(Locked)
Make use of the GUI of Visual Studio Code2m 51s
-
(Locked)
Challenge: Make a change and revert51s
-
(Locked)
Solution: Make a change and revert2m 22s
-
(Locked)
-
-