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.
Go back in Git history
From the course: Git Essential Training
Go back in Git history
- [Instructor] In the last video, we saw how we can see all previous states that have been kept in the Git history. Now let's take that a little further. Let's see how we can browse the code in an older version of our project. First, I'll start by listing the old commits by using git log --oneLine. There we go. Now, let's say I want to go back to the commit before I removed Example02. Here you can see why the commit messages are very handy. What I'll do is I'll copy the commit ID that is viewed here. Notice how it's only the first seven numbers of the ID that gives us enough characters to uniquely identify it. Then I'll use git checkout and I'll paste the ID. Press Enter. Now I've switched to that older version. You can see that some folders I've created later are now gone, and Example02.md is back. In my codespace or in Visual Studio Code, I can see that I am in the state right at the bottom. It is important to note that I am now in what we call a detached head state. This means that…
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)
-
-