You see the Git documentation saying things like
The branch must be fully merged in HEAD.
But what is Git HEAD
exactly?
HEAD^ means the first immediate parent of the tip of the current branch. HEAD^ is short for HEAD^1 , and you can also address HEAD^2 and so on as appropriate. The same section of the git rev-parse documentation defines it as. <rev>^ , e.g. HEAD^ , v1.5.1^0.
What is Origin (or Remote Head) in Git? The word origin is an alias that Git created to replace the remote URL of a remote repository. It represents the default branch on a remote and is a local ref representing a local copy of the HEAD in the remote repository.
In Git, a head is a ref that points to the tip (latest commit) of a branch. You can view your repository's heads in the path . git/refs/heads/ . In this path you will find one file for each branch, and the content in each file will be the commit ID of the tip (most recent commit) of that branch.
Head: Head is the repository containing the changes that will be added to the base. Following the example above, this is your repository (your fork of your colleague's repo).
You can think of the HEAD as the "current branch". When you switch branches with git checkout
, the HEAD revision changes to point to the tip of the new branch.
You can see what HEAD points to by doing:
cat .git/HEAD
In my case, the output is:
$ cat .git/HEAD ref: refs/heads/master
It is possible for HEAD to refer to a specific revision that is not associated with a branch name. This situation is called a detached HEAD.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With