将所有分支(children 和孙子)从他们的祖先变基
Rebase all the branches (both children and grandchilden) from their ancestor
我有一个 Git 存储库,如下所示:
A-B-F (master)
|\
C \ (feature-1)
D (feature-2)
\
E (feature-3)
是否有任何方法可以自动将所有功能分支(children 和孙子分支)变基为 F,如下所示?
A-B-F (master)
|\
C'\ (feature-1)
D' (feature-2)
\
E'(feature-3)
我已经查看了Rebasing a branch including all its children and How to rebase a series of branches?的回复,但他们都没有涵盖这个特定案例,也没有给出明确的答案。
答案与相关问题中的答案相同:git 中没有内置任何内容。您可以如下所述手动执行此操作。之后你可以尝试把它放在脚本中...
这是您手动完成的方式:
git checkout feature-1
git rebase master
git checkout feature-2
git rebase master
git checkout feature-3
git rebase feature-2
帮助您开始自己编写脚本:
git branch --contains <sha-1> | xargs -n 1 | grep -v "\*" | grep -v master
将为您提供包含提交 <sha-1>
的所有分支的列表。然后你可以看看this question找到如何找到一级后代的代码......把这两个信息放在一起;你将能够编写你想要的脚本。
我有一个 Git 存储库,如下所示:
A-B-F (master)
|\
C \ (feature-1)
D (feature-2)
\
E (feature-3)
是否有任何方法可以自动将所有功能分支(children 和孙子分支)变基为 F,如下所示?
A-B-F (master)
|\
C'\ (feature-1)
D' (feature-2)
\
E'(feature-3)
我已经查看了Rebasing a branch including all its children and How to rebase a series of branches?的回复,但他们都没有涵盖这个特定案例,也没有给出明确的答案。
答案与相关问题中的答案相同:git 中没有内置任何内容。您可以如下所述手动执行此操作。之后你可以尝试把它放在脚本中...
这是您手动完成的方式:
git checkout feature-1
git rebase master
git checkout feature-2
git rebase master
git checkout feature-3
git rebase feature-2
帮助您开始自己编写脚本:
git branch --contains <sha-1> | xargs -n 1 | grep -v "\*" | grep -v master
将为您提供包含提交 <sha-1>
的所有分支的列表。然后你可以看看this question找到如何找到一级后代的代码......把这两个信息放在一起;你将能够编写你想要的脚本。