THE GIT HEAD AND ITS IMPORTANCE

There are several definitions as to what “git head” is all about, this all depends on the user’s understanding of how it works. Lets keep this simple and short.

The HEAD is a symbolic reference to the last commit, i.e., it’s a pointer to another reference, showing the latest commit in the branch and thus making it the parent of the next commit, this reference also contains the secure hash Algorithm -1 (SHA-1) value. It’s simple to see the Head as the current branch, such that when you switch branches with “git checkout”, the HEAD revises changes to point to the tip of the new branch.

In addition, the heads of the branches are stored in .git/refs/heads/ directory.

WHAT IS THE IMPORTANCE OF GIT HEAD:

FETCH_HEAD tracks the HEAD of the most recently fetched branch from a remote repository.

ORIG_HEAD holds the reference to the HEAD before the “merge”, “commit”, “push” e.t.c., operations, so that one can easily change the tip of the branch back to the state before one runs them.

MERGE_HEAD records the commit(s) which you are merging into your branch when you run “git merge”.

“The head is indispensable, it’s key in programming.”

Like what you read? Give Gpearll a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.