Git不克隆后续克隆上的所有分支? [英] Git doesn't clone all branches on subsequent clones?

查看:230
本文介绍了Git不克隆后续克隆上的所有分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用克隆存储库和分支时,我遇到了一些Git问题,我无法找到答案。让我描述一下:我们有一个纯粹的主Git仓库,我们都从这里拉到并推送到位于本地linux机器上的可用ssh访问的仓库。

  git clone ssh:// adahl @ gollum // net我把这个复制到了我的usb拇指驱动器中/repos/netcube/patches.git 

这给我当然是一个工作副本的本地克隆我的拇指驱动器。我cd到这个,然后看到这个克隆中的一些分支:

  cd修补程序
git分支-a
* master
remotes / origin / HEAD - >起源/大师
遥控器/原产地/主人
遥控器/原产地/稳定型

到目前为止这么好,但是如果我将我的拇指驱动器上的存储库克隆到我的笔记本上,则稳定分支会丢失。请参阅:

  cd .. 
git克隆补丁patch2

cd patches2

git分支-a
* master
遥控器/ origin / HEAD - >原产地/主产地
遥控器/产地/主产地

code> git fetch 克隆后,没有任何东西将稳定的分支带到 patches2 存储库。我想我在这里缺乏理解git,只是用错了方式。有人可能会指出我在使用和/或理解方面的错误吗? 解决方案

请参阅如何在Git中克隆所有远程分支?



如果您确实希望将其包含在克隆中,则需要基于远程分支创建本地分支。但是,由于您不在远程分支中工作,只要您开始在分支上工作,就会创建本地分支。在此之前,您并不需要它,因为您可以随时从远程获取它。



但是,如果笔记本没有网络连接,您必须为您想要的所有远程分支机构创建本地分支机构,以便在克隆本地回购时克隆它们。



如果确实有网络连接,请使用 git remote add origin2 ssh://adahl@gollum//net/repos/netcube/patches.git 然后 git fetch origin2 - 随意用更有意义的名称替换 origin2


I have some problems with Git using cloned repositories and branches and it's somehow not possible for me to find an answer to this. Let me describe: we have a bare master Git repository here we all pull from and push to, located on a local linux machine and reachable with ssh. I made a clone of this to my usb thumb drive like this:

git clone ssh://adahl@gollum//net/repos/netcube/patches.git

This gives me of course a local clone with a working copy on my thumb drive. I cd to this and see some branches in this clone then:

cd patches
git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/stable

So far so good, however if I clone the repository on my thumb drive another time to my notebook the stable branch is lost. See:

cd ..
git clone patches patches2

cd patches2

git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master

I tried several options when cloning or a git fetch after cloning, nothing brings the stable branch to the patches2 repository. I assume I have a lack of understandig git here and simply use it the wrong way. Could someone please point me to my error in usage and/or understanding?

解决方案

See How to clone all remote branches in Git?

You need to create a local branch based on the remote branch if you actually want it to be included in a clone. However, since you don't work in remote branches anyway you'll create local branches as soon as you start working on a branch. And before that you don't really need it in your clone since you can simply fetch it from remote at any point.

However, if the notebook has no network connectivity, you'll have to create local branches for all remote branches you want so they are cloned when cloning your local repo.

If you do have network connectivity however, use git remote add origin2 ssh://adahl@gollum//net/repos/netcube/patches.git and then git fetch origin2 - feel free to replace origin2 with a more meaningful name.

这篇关于Git不克隆后续克隆上的所有分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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