Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does git push origin HEAD mean?

Tags:

git

git-push

People also ask

What does git pull origin head do?

But one of the notations that developers find themselves typing most often is git pull origin master : it downloads new changes from the branch named master on the remote named origin and integrates them into your local HEAD branch.

What is git head?

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 does git push origin master do?

git push origin master will push your changes to the remote server. "master" refers to master branch in your repository. If you want to push your changes to any other branch (say test-branch), you can do it by: git push origin test-branch. This will push your code to origin of test-branch in your repository.

What is the git push command?

The git push command is used to upload local repository content to a remote repository. Pushing is how you transfer commits from your local repository to a remote repo. It's the counterpart to git fetch , but whereas fetching imports commits to local branches, pushing exports commits to remote branches.


HEAD points to the top of the current branch. git can obtain the branch name from that. So it's the same as:

git push origin CURRENT_BRANCH_NAME

but you don't have to remember/type the current branch name. Also it prevents you from pushing to the wrong remote branch by accident.

If you want to push a different branch than the current one the command will not work.


If you want to push into the specific remote branch you can run:

git push origin HEAD:<name-of-remote-branch>

This is what I encounter when I was trying to push my repo back to the remote branch.