通过它的镜像裸机远程将所有分支从远程拉出 [英] Pull all branches from remote through it's mirror bare remote

查看:83
本文介绍了通过它的镜像裸机远程将所有分支从远程拉出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个裸露的遥控器(我们称它为group_origin).
我做了一个裸露的镜像克隆(my_origin).
git clone my_origin到具有工作目录(my_rep)的存储库.
my_rep我的代码中,推到my_origin并从my_origin拉出.

There is a bare remote (let's call it group_origin).
I made a bare mirror clone of it (my_origin).
I git clone my_origin to a repository with a working directory (my_rep).
In my_rep I code, push to my_origin and pull from my_origin.

当我的同事更新group_origin时,我从group_origin git获取my_origin.
我看到类型为group_origin/branch_1的标签(当我在my_origin内部执行git log时).因此,my_origingroup_origin上新创建的"分支branch_1的感知". 但是,当我以后在my_rep中的my_repgit loggit pull my_origin时,我看不到branch_1的任何提示.

When group_origin is updated by my colleagues, I git fetch my_origin from group_origin.
I see tags of the kind group_origin/branch_1 (when I execute git log inside of my_origin). Thus, my_origin is "aware of" newly created branch branch_1 on group_origin.
However, when I git pull my_origin from my_rep and git log within my_rep later, I don't see any notice of branch_1.

所以,我的问题是:
如何从my_origin(这反过来又是group_origin的裸镜)更新my_rep来获取group_origin/branch_1的新创建分支?

So, my question is:
how can I update my_rep from my_origin (which is in turn a bare mirror of group_origin) to fetch newly created branches of group_origin/branch_1?

推荐答案

您应该在my_origin中为group_origin中的每个分支创建跟踪分支.

You should create the tracking branches in my_origin for each and every branches from group_origin.

为此,我使用"单线 .com/q/379081/6309>将所有远程git分支跟踪为本地分支".

For that, I use that one-liner from the question "Track all remote git branches as local branches".

remote=origin ; for brname in `git branch -r | grep $remote | grep -v master | grep -v HEAD | awk '{gsub(/[^\/]+\//,"",$1); print $1}'`; do git branch --set-upstream-to $brname  $remote/$brname ; done

否则,默认情况下,my_origin仅声明一个分支(group_origin中的默认分支,由其 ).
而且,my_rep只会看到那个分支.

Otherwise, by default, my_origin will only declare one branch (the default one from group_origin, referenced by its symbolic-ref HEAD).
And, in turn, my_rep will see only that one branch.

另一种选择是将远程添加到本地存储库my_rep中,以直接监视group_origin.
(您可以添加想要或需要的任意多个远程上游上游存储库,只需查看它们的历史记录即可)

The other option is to add a remote to your local repo my_rep, for monitoring group_origin directly.
(You can add as many remote upstream repos that you want or need, just to have a look at their history)

cd my_rep
git remote add group_origin /url/to/group_origin
git fetch group_origin

这样,您将看到那些group_origin/branch_x,并可以决定创建一个并将其推送到my_origin.

That way, you will see those group_origin/branch_x and can decide to create one and push it to my_origin.

git checkout --track -b branch_x group_origin/branch_x

这篇关于通过它的镜像裸机远程将所有分支从远程拉出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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