What does git push origin HEAD mean?

前端 未结 2 1708
感动是毒
感动是毒 2020-12-22 23:31

I found, in the official guide:

git push origin HEAD

A handy way to push the current branch to the same name on the remote.

相关标签:
2条回答
  • 2020-12-22 23:45

    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.

    0 讨论(0)
  • 2020-12-23 00:03

    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.

    0 讨论(0)
提交回复
热议问题