通过它的镜像裸机远程将所有分支从远程拉出 [英] Pull all branches from remote through it's mirror bare remote
问题描述
有一个裸露的遥控器(我们称它为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_origin
是group_origin
上新创建的"分支branch_1
的感知".
但是,当我以后在my_rep
中的my_rep
和git log
中git 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
.
为此,我使用"
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屋!