Solution
Just execute the following command (replace <hash>
):
$ git checkout <hash>
Explanation
In order to make the jump from one confirmation (commit) to another, you must know the number (hash) by which it was registered. Taking into account that the official book of Git in Spanish, section 2.3 Fundamentals of Git - Viewing the confirmation history , tells us:
After having made several confirmations, or if you have cloned a repository that already had a history of confirmations, you probably want to look back to see what modifications have been made. The most basic and powerful tool to do this is the git log
command.
When you execute the git log
command on your project, you will have something like this:
$ git log
commit ca82a6dff817ec66f44342007202690a93763949
Author: Scott Chacon <[email protected]>
Date: Mon Mar 17 21:52:11 2008 -0700
Cambiado el número de versión
commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7
Author: Scott Chacon <[email protected]>
Date: Sat Mar 15 16:40:33 2008 -0700
Removido código de prueba innecesario
commit a11bef06a3f659402fe7563abf99ad00de2209e6
Author: Scott Chacon <[email protected]>
Date: Sat Mar 15 10:31:28 2008 -0700
Primera confirmación
The hash (or confirmation number) will be the alphanumeric set that is followed by the word commit . You will copy this hash to use it with the command git checkout <hash>
that will take care of moving the pointer HEAD of your project to the indicated confirmation. Visual example (taking into account that you are the project is the branch master
):
In this way we can perceive that although your pointer now points to a previous capture, your subsequent changes to it still exist.
You can get more official information and in Spanish related to this topic in the following link: 6.1 Git tools - Selection of confirmations of specific changes
Short SHA : Simply by giving it the first characters of the SHA-1 code, Git is smart enough to figure out what the desired commit (commit) is. It is necessary to type at least 4 characters and these must be unambiguous --ie, there must be a single object in the repository whose code starts with that initial piece of SHA -.