1.

What is ‘head’ in git and how many heads can be created in a repository?

Answer»

In every repository, there is a default head REFERRED to as “Master”. When you switch branches with git checkout, the HEAD revision changes to point to the tip of the new branch. A repository can contain any number of heads. While HEAD may regularly be portrayed as indicating the latest submit or indicating what branch you're on, neither one of the descriptions is very right.

It focuses on what you've at present looked at, pretty much, which may not be what's the most recent. HEAD is a COMMON content record in .git/HEAD, so you can investigate. So at this MOMENT, my HEAD CONTAINS:

  • ref:refs/heads/test

This IMPLIES I've looked at the 'test 'branch, which is indicated by the ref 'refs/heads/test'. That this is (usually*) put away in the record .git/refs/heads/test, and contains:

7fc4bd269202ead49b9e5d4fa5f8e7db1525ea5b which is the commit ID for that branch.

  • ~(Tilde) and ^(caret), pointing to the relative position of a commit. The most common is to add ~(Tilde) after the HEAD to point to the generation of the parent; 
  • ^(caret) can point to the previous generation of generations.


Discussion

No Comment Found