gitlab没有遥控器/原点/HEAD [英] No remotes/origin/HEAD with gitlab

查看:128
本文介绍了gitlab没有遥控器/原点/HEAD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对git还是很陌生,但是我一直在我设置的远程服务器上玩弄它,而且我很确定自己了解基本知识.

I'm pretty new to git, but I've been playing around with it on a remote server I set up and I'm pretty sure that I understand the basics.

我刚刚设置了gitlab并将我的一些代码推送到了一个新项目上.我所做的是:

I just set up gitlab and pushed some of my code to a new project on it. What I did was:

  1. 将我所有的代码保存在目录中
  2. git init
  3. git add.
  4. git commit -m初始提交"
  5. git push原始主机

原产地设置为:

git remote add origin git@1.2.3.4:myproject.git

现在,当我执行git branch -a时,我会看到:

Now when I do git branch -a I see:

* master
  remotes/origin/master

在我以前玩耍的时候,我总是看到:

Whereas when I was playing around before, I always saw:

* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master

我知道head是当前已签出分支的指针,所以它不应该存在于原点上吗?为什么不创建它?

I understand that the head is a pointer the currently checked out branch, so shouldn't it exist on the origin? Why wasn't it created?

推荐答案

不必为此远程HEAD担心.这条线只是原始克隆工作方式的产物,代表远程服务器的HEAD状态.

Don't worry much about this remote HEAD. This line is simply artifact of the way original clone works, and represents state of remote's HEAD.

可以将其视为服务器首选的默认分支(即使在远程裸仓库中)-如果未使用-b branch选项,则默认情况下,客户端git clone会将其检出.

It can be considered as a default branch that is preferred by server (even on remote bare repository) - it will be checked out by your client git clone by default if -b branch option was not used.

您的本地文件.git/refs/remotes/origin/HEAD现在可能包含字符串ref: refs/remotes/origin/master.您可以根据需要删除它(不是,我建议您不要这样做),git branch -a将不再显示它.

Your local file .git/refs/remotes/origin/HEAD probably contains string ref: refs/remotes/origin/master now. You can remove it if you want (not that I recommend doing it, mind you), and git branch -a will not show it anymore.

除了将远程HEAD用作第一个克隆的默认分支外,对于远程HEAD的状态永远都没有关系.您只需要担心真正的远程分支的状态,而不必担心远程HEAD,因为它仅对于将远程状态作为其默认选定分支有意义.而且,如果远程是裸露的存储库,那么即使在远程上也没有多大意义.

Except for this usage of remote HEAD as default branch for first clone, for you state of remote HEAD never matters. You should only worry about state of real remote branches, not remote HEAD as it only makes sense for remote state as its default selected branch. And if remote is bare repository, it does not make much sense even on remote.

git remote add ...git fetchgit pull时为什么没有看到远程HEAD的原因是,在这种情况下git不必决定默认使用哪个默认远程分支.

And the reason why you did not see remote HEAD when you did git remote add ..., git fetch, git pull is because in that case git did not have to make a decision on which default remote branch to pickup by default.

这篇关于gitlab没有遥控器/原点/HEAD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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