What are the head and orig_head pointers in git?

Source: Internet
Author: User
Tags using git

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_HEADRoll 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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.