维护不同分支的补丁集
我负责生成一系列文档补丁,每个补丁都适用于多个分支。该项目使用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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
新答案
您似乎正在寻找;这是手册页。
git-cherry-pick
。该命令用于获取命名提交并将其提交到当前分支。基本语法是 gitcherry-pick但是,您应该尽可能避免挑选,因为它会创建重复的提交,并且您确实希望将它们视为合并。您应该尝试采用“向上合并”的分支工作流程。来自 man gitworkflows :
在您的情况下,您应该能够将文档更新分为几个类,例如“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 isgit 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
: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.