Go to any revision in Git

Being able to go to any revision of code managed by a Version Control System is a very important thing for a programmer. It helps us to see how our code is at that moment. In this tutorial, I will show you how we can pass the source code to any revision with Git.

I will take the css-selector library with source code on GitHub at https://github.com/chrsan/css-selectors to illustrate this tutorial.

Tool

Git: https://git-scm.com/

First we need to update our source code to the latest version and then we will use the reset statement to make the move to any revision.

Update the source code

Right-click on the css-selector project and select Git Bash Here.

Go to any revision in Git

We will update the source code to the latest version using the following command line:

Result:

Go to any revision in Git


Select a revision

Using Git, we can see all the revision information we want to include in the source code.

Right-click on the project and select Git Bash Here.

Enter gitk in the command line, a new window will open showing the history of the css-selector library.

Go to any revision in Git

Go to a revision

For example, now we need to include the source code of the css-selector library to revision 0d7e377867307879d59c54963ba47811bef67158.

We will continue to use Git Bash Here and execute a command like this:

Go to any revision in Git

Result:

Go to any revision in Git

Đánh giá bài viết
Chia sẽ bài viết này ...Share on Facebook
Facebook
0Tweet about this on Twitter
Twitter
Share on LinkedIn
Linkedin

Add Comment