Then the example of the previous section
We add another piece of content to the README.txt file (add modify1):
1 add a file called README2 add modify1
Then commit to the repository
View Logs
The $ git log git log command displays the commit log from the most recent to the farthest, using a record of each commit of the display file
If too many output information, see dazzling, you can try to add –pretty=oneline parameters:
Note: 24ee419cb72e7a7baa5814787dd2a63dfe031a34 is a commit ID (version number), unlike SVN, GIT's commit ID is not ... Incrementing the number, but a SHA1 calculated by a very large number, in hexadecimal notation, and you see the commit ID is not the same as mine, whichever is your own
Fallback version
Each time a new version is submitted, git actually automatically strings them into a timeline. Each submitted version is on this timeline and we can roll back to any version.
Fallback git must know which version of the current version, in Git, with the head of the current version, that is, the latest submitted, the previous version is head^, the last version is head^^, of course, 100 to write 100 ^ is more easy to count, so write head~ 100.
For example: We are going to go back to the previous version 1 add a file called README and need to use the git reset command
$ cat README.txtAfter you can see the README.txt content only 1 add a file called README , has gone back to the previous version
Look at the git log record again and you'll see that the second version of the history is missing.
Back up and back to the new version
If you want to go back to the second version, as long as the above command Line window has not been turned off, you can go up and find the second version of the commit ID is 3628164 ..., you can specify back to the second version, this method for each version of the past, if you want to know that version of the commit Id
So found that the second version is back, the version number is not necessary to write the whole, the first few can be, git will automatically go to find. Of course, you can't just write the top one or two bits, because git might find multiple version numbers, and there's no way to determine which one.
Git's version fallback is very fast, because Git has a head pointer to the current version inside, and when you roll back the version, Git simply changes the head from the second version to the previous version, so you have the head point to which version, and you're positioning the current version.
What if I fall back to a version and want to go back to the new version, but can't find the commit ID? In fact, there is a way, git provides a command git reflog used to record each of your commands:
So you can find the commit ID of each of your commands.
Git operations-version fallback