gitlab 没有遥控器/来源/HEAD [英] No remotes/origin/HEAD with gitlab

查看:13
本文介绍了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 初始化
  3. git 添加.
  4. git commit -m "初始提交"
  5. git push origin master

原点的设置位置:

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 分支,它将由您的客户端 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 因为它只对远程状态作为默认选择的分支有意义.如果 remote 是裸存储库,即使在 remote 上也没有多大意义.

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 fetch, git pull 的时候没有看到remote 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天全站免登陆