1.上一节讲了重置命令,重置命令是修改了引用的游标指向,重置命令所针对的是头指针HEAD,之所以没有修改HEAD内容,是因为HEAD指向了一个引用refs/heads/master,所以重置命令体现为分支游标的变更,HEAD本身一直指向的是refs/heads/master,并没有在重置时改变.
2.而检出命令(git checkout)的实质是修改HEAD本身的指向,该命令不会影响分支.
2.而检出命令(git checkout)的实质是修改HEAD本身的指向,该命令不会影响分支.
3.HEAD是当前工作区的"基础版本",当执行提交时,HEAD指向的提交作为新提交的父提交.
bluceshang@bluceshang:~/gittemp$ cat .git/HEAD
ref: refs/heads/master
bluceshang@bluceshang:~/gittemp$ git branch -v
* master 3dad65f test reset amend
可以看出当前处于master分支.现在使用git checkout.
bluceshang@bluceshang:~/gittemp$ git checkout 3dad65f^
Note: checking out '3dad65f^'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now