Git分支名为origin / HEAD - >产地/主 [英] Git branch named origin/HEAD -> origin/master

查看:176
本文介绍了Git分支名为origin / HEAD - >产地/主的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Git相当陌生,并且仍然掌握着它。我刚刚开始与分支机构合作,并遇到了一些问题。



我有两个开发系统,一个是Ubuntu桌面和一个MacBookPro。我在Ubuntu系统的一个新的 organizations 分支中做了一大堆工作,并执行了提交并推送到我的远程仓库。在这一点上,我有这些分支:

$ pre $ ta $ $ c $ tauren @ ubuntu:/ projects $ git branch
accounting
master
组织

tauren @ ubuntu:/ projects $ git分支-r
来源/记帐
来源/主记录
来源/组织
origin / superstar

然后我切换到MBP来拉新分支:



$ $ $ $ $ $ $












$ b $ osx:/ projects $ git branch -r
origin / HEAD - >产地/主产地
产地/会计
产地/主产地
产地/超级巨星

tauren @ osx:/ projects $ git pull
2e20a14..ef35730会计 - >来源/会计
271a1a5..7e947ab master - > origin / master
* [new branch]组织 - >来源/组织

tauren @ osx:/ projects $ git branch
*会计
master

tauren @ osx:/ projects $ git branch -r
origin / HEAD - >原产地/主产地
产地/会计
产地/主产地
产地/组织
产地/超级巨星

所以我的问题是这些:


  1. 为什么MBP有一个分支 origin / HEAD - > origin / master ,但Ubuntu系统不?这个分支是什么?

  2. 是否自动拉出所有新的远程分支? git pull 我想我必须告诉它新的分支名称。正如你所看到的那样,它会在命令 git pull 中拉远程组织分支。


解决方案

HEAD 通常指向当前签出的分支。在托管(裸)存储库中,它指定默认分支,即克隆存储库时检出的分支。因此,origin / HEAD会告诉您默认的原始分支。



我不知道为什么它不在Ubuntu系统的存储库中。也许你最初是从你的代码库(当origin是空的,因此没有HEAD)推动你的代码,并且从未更新它。



有类似origin / HEAD无论如何,它在实践中并不是非常重要。



回答您的其他问题:如果您运行 git pull ,它实际上从远程获取所有内容( git fetch 也是在没有参数的情况下运行的,所以它只是获取所有内容)。尽管如此,一切都没有合并。只更新远程跟踪分支( git分支-r 中的内容)。


I'm fairly new to Git, and still getting the hang of it. I just recently started working with branches and am running into some questions.

I have two development systems, an Ubuntu desktop and an MacBookPro. I did a bunch of work in a new organizations branch on the Ubuntu system and performed commits and pushed to my remote repo. At this point, I had these branches:

tauren@ubuntu:/projects$ git branch
  accounting
  master
* organizations

tauren@ubuntu:/projects$ git branch -r
  origin/accounting
  origin/master
  origin/organizations
  origin/superstar

Then I switched to the MBP to pull the new branch:

tauren@osx:/projects$ git branch
  accounting
* master

tauren@osx:/projects$ git branch -r
  origin/HEAD -> origin/master
  origin/accounting
  origin/master
  origin/superstar

tauren@osx:/projects$ git pull
   2e20a14..ef35730  accounting -> origin/accounting
   271a1a5..7e947ab  master     -> origin/master
 * [new branch]      organizations -> origin/organizations

tauren@osx:/projects$ git branch
* accounting
  master

tauren@osx:/projects$ git branch -r
  origin/HEAD -> origin/master
  origin/accounting
  origin/master
  origin/organizations
  origin/superstar

So my questions are these:

  1. Why does the MBP have a branch origin/HEAD -> origin/master, but the Ubuntu system doesn't? What is that branch?
  2. Does git pull automatically pull all new remote branches? I thought I had to tell it the name of new branches to pull. As you can see, it pulled the remote organizations branch on the commmand git pull.

解决方案

HEAD usually points to the currently checked out branch. In hosted (bare) repositories, it designates the default branch, i.e. the branch that is checked out when you clone the repository. So, origin/HEAD tells you the default branch of origin.

I don't know why it's not present in your repository on the Ubuntu system. Perhaps you originally pushed your code from that repository (when origin was empty and thus didn't have a HEAD yet) and never updated it.

Having something like origin/HEAD is not terribly important in practice, anyway.

To answer your other question: if you run git pull without arguments, it actually fetches everything from the remote (git fetch is run without arguments, too, so it just gets everything). Everything doesn't get merged, though. Only the remote-tracking branches (the stuff in git branch -r) are updated.

这篇关于Git分支名为origin / HEAD - >产地/主的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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