Git - Head (Head Branch | Branch Head)

About

This article is about the head, for the HEAD branch see the current branch page.

Example

In the example below, the branch head of:

  • the branch A is the commit CA3
  • the branch B is the commit CB2
             CA1--CA2--CA3 <-- Branch A
            /
 CM1--CM2--CM3 <-- master
            \
             CB1--CB2 <-- Branch B

Management

Detached

Detached head means you are no longer on a branch, you have checked out a single commit in the history

Resolution:

git checkout master
git checkout yourBranch

Show

Local branch

With the log

git log -n 1 [branch_name]

List

Local value

local: head of the branchs are stored in the git directory in the log directory

ls .git\logs\refs\heads
master  
branch-a
branch-b

remote value

git ls-remote --heads remote
dd39a644a4a7ec3e65135baaf48acd5f7f628510        refs/heads/master
6ead0945771dfd789aa97442ff10872f9665598d        refs/heads/stable
e245797039fa7b86c3a3fb32b45cfb998d8c76cd        refs/heads/v1.13

Reset / revert

Reset, revert to the head commit of the upstream branch

git reset --hard upstream/master

Powered by ComboStrap