我怎样才能看到另一个分支是从哪个分支分出的? [英] How can I see what branch another branch was forked from?
问题描述
我的git仓库有三个分支, devel
, stable
和 customers / acme_patches
。很久以前, stable 从
devel
分支出来,并且所有错误修复发生在稳定
。现在, stable
会被合并回 devel
。 customers / acme_patches
是一个分支,它包含一些客户特定的补丁。该分支未被合并到 devel
和 stable
中。
一些ASCII艺术来说明这种情况:
o --- o --- o customers / acme_patches?
/
o --- o --- 1 --- o --- o --- o stable
/ \\
o --- o- --o --- 2 --- o --- o --- o --- o devel
\
o --- o --- o customers / acme_patches?
现在我想知道:
什么分支是 customers / acme_patches
从 - devel
或 stable
分叉我只知道它过去曾分出其中一个,但我不知道是哪一个。例如。它可能是在上面的图中提交 1
或 2
。
我一直在玩 git log --oneline --graph
和 gitk
,但是自从 customers / acme_patches
在几百次提交之前被分叉了,很难跟着画出的线。
一个快速的命令(一个小脚本也可以),它可以以某种方式向后追踪 customers / acme_patches
中的提交,以找到带有两个子项(叉点)的第一个提交和然后确定该提交是在 stable
还是在 devel
中完成?
$ b $在最好的情况下,我可以只执行一些类似的东西(原谅提示符,我在Windows上):
C:\src> git fork-origin customers / acme_patches
stable
好吧,这个答案可能没有完美的解决方案。我的意思是在git中没有 fork-origin
等效(据我所知)。
因为 stable
分支被合并到 devel
中,所以 acme_patches
(从1开始)位于 devel
和 stable
分支。
你可能做的是:
$ g $ git branch --contains $(git merge-base customers / acme_patches devel stable)
如果你有稳定而不开发,或者开发并且不稳定,那么你知道它来自哪里。
例如,在案例2中,您将拥有
$ git branch --contains $(git merge-base customers / acme_patches devel stable)
customers / acme_patches
devel
而在案例1中,您将拥有
$ git分支 - -contains $(git merge-base customers / acme_patches devel stable)
customers / acme_patches
devel
stable
因为它现在在两个分支上(因为从stable到dev的合并)
My git repository has three branches, devel
, stable
and customers/acme_patches
. A long time ago, stable
was forked from devel
, and all the bugfixing takes place in stable
. Every now and then, stable
is merged back into devel
. customers/acme_patches
is a branch with a few customer-specific patches. The branch wasn't merged into either of devel
and stable
.
A bit of ASCII art to illustrate the scenario:
o---o---o customers/acme_patches? / o---o---1---o---o---o stable / \ \ o---o---o---2---o---o---o---o devel \ o---o---o customers/acme_patches?
Now I wonder:
What branch was customers/acme_patches
forked from - devel
or stable
? I only know that it was forked off one of them in the past, but I don't know which. E.g. it might have been commit 1
or 2
in the above diagram.
I've been playing around with git log --oneline --graph
and gitk
but since customers/acme_patches
was forked a few hundred commits ago, it's hard to follow the lines being drawn.
Is there maybe a quick command (a little script is fine, too) which can somehow follow the commits in customers/acme_patches
backwards to find the first commit with two children (the fork point) and then determines whether that commit was done in stable
or in devel
?
In the best case, I could just execute something like (excuse the prompt, I'm on Windows):
C:\src> git fork-origin customers/acme_patches
stable
Well, there is probably no perfect solution to this answer. I mean there is no fork-origin
equivalent in git (to my knowledge).
Because the stable
branch is merged into devel
, your acme_patches
(from 1) is on both devel
and stable
branch.
What you could possibly do is:
git branch --contains $(git merge-base customers/acme_patches devel stable)
If you have stable and not devel, or devel and not stable, then you know where it comes from.
For example, in the case 2, you would have
$ git branch --contains $(git merge-base customers/acme_patches devel stable)
customers/acme_patches
devel
while in case 1 you would have
$ git branch --contains $(git merge-base customers/acme_patches devel stable)
customers/acme_patches
devel
stable
As it's now on both branches (because of the merge from stable to dev)
这篇关于我怎样才能看到另一个分支是从哪个分支分出的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!