Git - Head (Head Branch | Branch Head) / Last commit

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]

Get

with rev-parse

git rev-parse HEAD

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





Discover More
Card Puncher Data Processing
Code Versioning - Branch (Line of Development)

The word branch means a line of development. The first one is generally call the master. tree pathhead in git A branch is a sort of sandbox. A branch can be made for: new features to follow the...
Git

is a content-addressable file system used to track directory tree content (as defined by its creator Linux Torvald) It's not a version control...
Git Commit Tree Data Model
Git - Commit

A commit in git is an object that stores the information : who saved the file system snapshots, when they were saved, why they were saved. the commiter the author the parent commit It's...
Git - Current / working / HEAD / active branch

The current or active branch is: the branch checked out actually in the working tree The current branch is also known as the HEAD branch (in uppercase) that represents the last commit known...
Git - Detached HEAD

What means a DETACHED HEAD in git
Git - Fetch (Remote Repository Sync)

A fetch will sync information locally from a remote repository. It will receive missing objects from another repository. It will mostly git fetch: download new remote branch download all commits...
Git - Local branch

A local branch is a branch that exists only on your computer. tracking branch There are two types of local branches: non-tracking local branches. They are not associated with any other branch....
Git File System
Git - Tree Object

In Git, a tree is an object that corresponds to file system directory in the git file system. A single tree object contains: one or more entries, each of which is the SHA-1 hash of a blob or subtree...
How to perform a text file diff in Git?

This page is text file diff in Git Diff between the head commit of the current branch (HEAD) and the current file not yet committed (in the working area) Between the head of the main branch...
Branches Git
What is a Git Branch ?

This page talks Branch management in Git. For Git, a branch is: a commit name (ref) that points to the last commit (head) leaf in the commit log (or log) that represents a commit chain Example...



Share this page:
Follow us:
Task Runner