Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Our git repository has a branch called HEAD

Tags:

git

git-branch

I recently noticed that our git server has a branch called HEAD. I've tried doing this locally and git warns me that this is ambiguous. Are there any potential horrible problems we could encounter by deleting/renaming this branch?

like image 644
Boumbles Avatar asked May 06 '13 18:05

Boumbles


People also ask

Is head a branch Git?

When working with Git, only one branch can be checked out at a time - and this is what's called the "HEAD" branch. Often, this is also referred to as the "active" or "current" branch. Git makes note of this current branch in a file located inside the Git repository, in . git/HEAD .

What is the head of a repo?

The term HEAD refers to the current commit you are viewing. By default, you'll view the tip of the master branch on a repository, unless the main branch of your repository has a different name. The tip of the master branch is the most recent commit on the main branch of your codebase.

What is a head Git?

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.

How do I find my Git head?

The git show head is used to check the status of the Head. This command will show the location of the Head. Syntax: $ git show HEAD.


2 Answers

Your server should have a branch pointer called HEAD, which will point to your default branch. By default, git branch -r will show you this:

origin/HEAD -> origin/master
like image 116
meagar Avatar answered Oct 08 '22 20:10

meagar


It is normal for a bare repo to have a 'HEAD'. Keep in mind that HEAD is not a normal branch, but rather it is a pointer to a branch.

  1. For a non-bare the 'HEAD' "branch" is points to the checked out branch.
  2. For a bare repo, it points to the default branch, i.e. the branch checked out as the working dir when the bare repo is cloned to a non-bare repo. Often it points at "master", but you can point it to a different branch.
like image 36
Bert F Avatar answered Oct 08 '22 21:10

Bert F