After a version rollback, the following figure is displayed in the history:
The master and Dev pointers point to the local master branch and Dev branch, and the origin/master and origin/dev point to the master branch and Dev branch of the remote warehouse, which is easy to understand.
The head pointer indicates the current working path. Pointing to the same ID of the head and master indicates that the head is in the master branch, which is not hard to understand.
What is the orig_head pointer? I flipped through the official instruction documents and did not find any description of this pointer.
After searching, I got a little bit clear.
For some dangerous operations, git provides the rollback function by recording the last position of the head pointer orig_head. You can usegit reset --hard ORIG_HEAD
Roll back to the previous reset.
After version 1.8.5, git added the [email protected] {} function, which records the head's moving path through a linked list.
Enter $ git reflog, and the result is similar:
$ git reflogea34578 [email protected]{0}: reset: moving to HEAD^d628164 [email protected]{1}: commit: xxxea34578 [email protected]{2}: commit: xxxxcb926e7 [email protected]{3}: commit: xxxx
Every time you move the head pointer, git Concatenates the moving path through the linked list. The [email protected] {0} in the linked list header is the head pointer.
However, [email protected] {1} is not necessarily orig_head! Note that the original value of the head pointer is changed only when dangerous operations (such as merge) are performed on the orig_head, the [email protected] {} linked list records the movement of each head (including commit ).
Consider the following:
- 1. Commit-> 2. merge-> 3. Commit
[Email protected] {0}, [email protected] {1}, and [email protected] {2} Point to 3, 2, and 1, respectively, while orig_head points to 1 rather than 2.
Obviously, with the reflog command, the head linked list is easier to use than the orig_head that has never been changed. Therefore, if you are using git after version 1.8.5, we recommend that you use the head {} linked list instead of the orig_head pointer.
This article first http://www.dss886.com, reproduced please note
What are the head and orig_head pointers in git?