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

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