git push origin HEAD是什么意思? [英] What does git push origin HEAD mean?

查看:1589
本文介绍了git push origin HEAD是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在官方指南中发现:


git push origin HEAD



推送当前分支到远程
同名。

然而,命令的含义并不清楚我。为什么会有这种效果?



我一直无法找到答案(这个问题似乎可以解决这个问题,但是这个标题有误导性)。 解决方案

HEAD 指向当前分支的顶部。 git 可以从中获取分支名称。所以它是一样的:

  git push origin CURRENT_BRANCH_NAME 

但您不必记住/键入当前分支名称。也可以防止你意外推送到错误的远程分支。



如果你想推送一个不同于当前分支的分支,那么命令将不起作用。

>

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.

However, the meaning of the command is not clear to me. Why does it have this effect?

I haven't been able to find an answer (this question seems to treat the problem, but the title is misleading).

解决方案

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.

这篇关于git push origin HEAD是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆