维护不同分支的补丁集

发布于 2024-08-08 13:53:43 字数 113 浏览 5 评论 0原文

我负责生成一系列文档补丁,每个补丁都适用于多个分支。该项目使用Git进行版本控制。

补丁应按原样干净地粘贴在这些树枝的顶部。

以最小的努力将补丁应用到多个分支的最佳工作流程是什么?

I'm in the position of generating a series of documentation patches each of which applies to more than one branch. The project uses Git for version control.

The patches should apply cleanly on top of these branches as they are.

What is optimal workflow for applying the patches to multiple branches with minimal effort?

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

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

发布评论

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

评论(1

于我来说 2024-08-15 13:53:43

新答案

您似乎正在寻找git-cherry-pick。该命令用于获取命名提交并将其提交到当前分支。基本语法是 gitcherry-pick;这是手册页

但是,您应该尽可能避免挑选,因为它会创建重复的提交,并且您确实希望将它们视为合并。您应该尝试采用“向上合并”的分支工作流程。来自 man gitworkflows :

始终将您的修复提交到需要它们的最旧的受支持分支。然后(定期)将集成分支向上合并。

这提供了非常受控的修复流程。如果您注意到您已经对例如 master 应用了维护中也需要的修复,那么您将需要向下挑选它(使用 git-cherry-pick(1))。这种情况会发生几次,除非您非常频繁地这样做,否则无需担心。

在您的情况下,您应该能够将文档更新分为几个类,例如“featureA-documentation”,每个类都将合并到一个或多个分支中。您可以轻松地为自己编写一个脚本来自动检查各个分支并合并到适当的主题中。

旧答案

如果您好奇,请查看编辑历史记录 - 这些解决了如何通过推送或补丁提交将补丁从本地存储库的多个分支获取到远程分支。

New answer

You seem to be looking for git-cherry-pick. This command is used to grab a named commit and commit it to the current branch. The basic syntax is git cherry-pick <commit>; here's the man page.

However, you should avoid cherry-pick when possible, since it creates duplicate commits, and you'd really like to see them as merges. You should try to adopt a branch workflow that "merges upwards". From man gitworkflows:

Always commit your fixes to the oldest supported branch that require them. Then (periodically) merge the integration branches upwards into each other.

This gives a very controlled flow of fixes. If you notice that you have applied a fix to e.g. master that is also required in maint, you will need to cherry-pick it (using git-cherry-pick(1)) downwards. This will happen a few times and is nothing to worry about unless you do it very frequently.

In your case, you should be able to divide up your documentation updates into several classes, e.g. "featureA-documentation", each of which will be merged into one or more branches. You could easily write yourself a script to automate checking out the various branches and merging in appropriate topics.

Old answers

Look at the edit history if you're curious - these addressed how to get patches from multiple branches from the local repo into a remote one, with push or patch submission.

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