如何挑选其他合并路径?

发布于 2024-12-28 13:53:39 字数 668 浏览 2 评论 0原文

我有这样的结构:

   B - C - D <- feature
  /         \  
 A-----------E <- master  
 ^ mytag

B、C 和 D 提交是功能分支路径。 A 是公共基数。此功能作为 E 提交合并回 master。我已经标记(自动)提交 A。

我希望在没有用户干预(来自脚本)的情况下自动进行,无论功能分支中有多少提交,都可以将“mytag”选为“master”作为 A、E(在本例中) )在另一个分支。

现在,如果我这样做:

git checkout other    
git cherry-pick mytag..master

它将选择 A、B、C、D 和 E 提交。我希望它只从主分支(即 A 和 E)中选择提交。 注意:我不想以相反的方式合并到 E 中。我希望它能融入到母版中。 A 到 E 根本不确定这是分支。它可能是 A --- E。只是我需要类似“..”运算符的东西,但要使用其他分支的方式。

感谢您提前的帮助!

此外: 第三个分支是我应该挑选的,应该看起来像这样:

F - G - H - A - E <- other 

即 A 和 E 将在“其他”分支中挑选。

I have this structure:

   B - C - D <- feature
  /         \  
 A-----------E <- master  
 ^ mytag

B, C and D commits are feature branch path. A is a common base. This feature is merged back into master as E commit. I have tagged (automatically) commit A.

I would like automatically without user intervention (from script), no matter how many commits are there in the feature branch to cherry pick "mytag" to "master" as A, E (in this case) in another branch.

Now if I do:

git checkout other    
git cherry-pick mytag..master

it will pick A, B, C, D and E commits. I would like it to pick commits only from master branch, i.e. A and E.
Note: I don't want to merge into E in the opposide way. I want it feature into the master. And A to E is not sure that is branching at all. It could be A --- E. Just I need something like ".." operator, but to use other branch'es way.

Thanks for the help in advance!

In addition:
The third branch were I should cherry-pick, should look like that after:

F - G - H - A - E <- other 

i.e. A and E will be cherry-picked in "other" branch.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无敌元气妹 2025-01-04 13:53:39

这就是答案:

call git cherry-pick -m 1 --first-parent mytag..master
if %errorlevel% == 128 then call git cherry-pick --first-parent mytag..master

--first-parentcherry-pick的未记录选项。我在 log 命令中看到它,它也适用于前者。它正在做我需要的事情。默认情况下,要遍历第一个父级,而不是分支。

git log --first-parent mytag..master

仅返回 AE 提交。
-m 1 选项仅用于合并提交,对于非合并提交失败,反之亦然。所以我尝试使用,如果失败-不使用。

This is the answer:

call git cherry-pick -m 1 --first-parent mytag..master
if %errorlevel% == 128 then call git cherry-pick --first-parent mytag..master

--first-parent is undocumented option of cherry-pick. I saw it in log command and it is working for former, too. It is doing exactly what I need. To traverse first parent, not branch'es one as is by default.

git log --first-parent mytag..master

is returning only A and E commits.
-m 1 option is used only for merge commits and fail for non-merge commits and vice verse. So I try with and if it fail - without.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文