Git Push Origin Head

Abdul Jabbar Sep 28, 2022
  1. Git Push Command
  2. Git Push Origin Head Command
Git Push Origin Head

In this article, we will discuss the procedure to push the current branch with a similar name to the local repository to the remote repository using the Git commands.

Git Push Command

Suppose the developer wants to name the remote repository the same as the local repository. In that case, they have to run the git push command followed by the branch name every time, and this scenario seems to be much more hectic for the developer to mention the branch name every time they need to push the code to the server.

What if we type the single command every time for naming the remote repository? This step will make the developer’s life much easier and not be worried about the repository name every time.

Git Push Origin Head Command

Developers frequently push the latest work on their branches because other team members can access and utilize the code easily, so as per this situation, HEAD indicates the most recent commit on the branch. A user-friendly way to push the current branch name to remote is mentioned below.


git push origin HEAD

Here, the git push is executed consistently across different branches. Whereas HEAD indicates the peak (top) of the current branch, and Git will pick the branch name from that.

So it’s equivalent to the command.


git push origin CURRENT_BRANCH_NAME

The git push will capture the remote name pursued by a local branch name. This command will work by default until this branch name is equal to the branch name on the remote.

Let’s say we execute the following command.


git push origin

This command will not work because Git can’t counterpart the local branch name with the origin in the local repository. After that, if we set the tracking branch to the one we want to push to, it will work fine.

In some cases, developers want to push the local branch to the remote one with a unique name as per the project requirements or standards followed in the organization, and they can make it possible by mentioning the remote branch name exactly after writing the local branch name, and nothing that a colon should separate it.

It can be done by running the following commands.

git push origin register:new–branch


git push origin HEAD:new–branch
Author: Abdul Jabbar
Abdul Jabbar avatar Abdul Jabbar avatar

Abdul is a software engineer with an architect background and a passion for full-stack web development with eight years of professional experience in analysis, design, development, implementation, performance tuning, and implementation of business applications.


Related Article - Git Push