Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between HEAD and master

People also ask

Is head same as master in Git?

The simple answer is that HEAD is a pointer/label to the most recent commit of the branch you are currently on. master is the default branch created when you initialized a git repository (e.g. git init ). You can delete the master branch (e.g. git branch -D master ). You cannot delete the HEAD pointer.

What is a master head?

1 : the top of a mast. 2a : the printed matter in a newspaper or periodical that gives the title and details of ownership, advertising rates, and subscription rates. b : the name of a publication (such as a newspaper) displayed on the top of the first page.

What is origin master and head?

HEAD is not the latest revision, it's the current revision. Usually, it's the latest revision of the current branch, but it doesn't have to be. master is a name commonly given to the main branch, but it could be called anything else (or there could be no main branch). origin is a name commonly given to the main remote.

What is head of master branch?

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.


master is a reference to the end of a branch. By convention (and by default) this is usually the main integration branch, but it doesn't have to be.

HEAD is actually a special type of reference that points to another reference. It may point to master or it may not (it will point to whichever branch is currently checked out). If you know you want to be committing to the master branch then push to this.

Here is a visual example:

alt text

On your own repository you can check where the HEAD is pointing to by running this:

$ git symbolic-ref HEAD
refs/heads/master

However, finding out where the remotes/origin/HEAD is pointing to is more tricky because it is on the remote machine.

There is a great little tutorial on git references here:

http://people.gnome.org/~federico/news-2008-11.html#pushing-and-pulling-with-git-1


The simple answer is that HEAD is a pointer/label to the most recent commit of the branch you are currently on. master is the default branch created when you initialized a git repository (e.g. git init).

You can delete the master branch (e.g. git branch -D master). You cannot delete the HEAD pointer.


Simply push the changes of your current branch

git push origin

and it will push your branch 'B' changes to 'origin/B'.
If you are on your master branch, git will push to origin/master.
Actually it will push all changes on the local branches that have matching remote branches at origin. It is controlled by the config setting push.default.
See also pushing RefSpecs in the Pro Git book.


What you are seeing is the sidebar representing all the refspecs of your remote repo in the Experimental GitX fork of the GitX project.

alt text

The HEAD will designate the default branch for that remote.
See git remote set-head man page:

Having a default branch for a remote is not required, but allows the name of the remote to be specified in lieu of a specific branch.
For example, if the default branch for origin is set to master, then origin may be specified wherever you would normally specify origin/master.