获取远程遥控器和远程远程分支
我想获取远程存储库的远程分支。
因此,例如,在这种情况下 —
$ cd alpha
$ git remote
beta
$ git branch -a
master
remotes/alpha/master
$ cd ../beta
$ git remote
gamma
$ git branch -a
master
remotes/gamma/slave
— 我想通过 gamma
的 slave
分支将其提取到 alpha
存储库中代码>测试版。这可能会添加 gamma
作为 alpha
的远程,并使用 gamma/slave
作为新分支的 refspec。我不一定想创建本地跟踪分支。与示例不同,我也不一定具有对 beta
或 gamma
的文件系统访问权限。
这种事情可以通过 $ git clone --mirror 来完成,但是有没有办法在已经存在的存储库中做到这一点?
I'd like to fetch the remote branches of a remote repository.
So, for example, in this situation —
$ cd alpha
$ git remote
beta
$ git branch -a
master
remotes/alpha/master
$ cd ../beta
$ git remote
gamma
$ git branch -a
master
remotes/gamma/slave
— I'd like to fetch gamma
's slave
branch into the alpha
repository by going through beta
. This would presumably add gamma
as a remote of alpha
and use gamma/slave
for the new branch's refspec. I don't necessarily want to create a local tracking branch. I also don't necessarily have filesystem access to beta
or gamma
, unlike in the example.
This sort of thing can be done with $ git clone --mirror
, but is there a way to do it in an already-existing repo?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来设置一个非默认的 refspec 会让我半途而废。
例如,考虑以下设置:
初始化
gamma
初始化
beta
并将gamma
添加为遥控器:克隆
beta
以制作alpha< /代码>:
现在变得激烈:
所以执行 `$ git fetch '+refs/:refs/< /em>' 将拉入分支本身,但不会更新构成其所属远程的配置项。
有趣的是,为无远程分支设置跟踪分支将导致它开始跟踪自己的存储库:
我认为这实际上不起作用。
It looks like setting a non-default refspec will get me partway there.
For example, consider this setup:
Initialize
gamma
Initialize
beta
and addgamma
as a remote:clone
beta
to makealpha
:Now get fierce:
So doing a `$ git fetch '+refs/:refs/' will pull in the branch itself, but will not update the configuration items that constitute the remote that it belongs to.
Interestingly, setting a tracking branch for the remoteless remote branch will cause it to start tracking its own repo:
I think this doesn't really work.