Git 合并分支之间的提交
我有两个分行。让我们称它们为A&暂时是B。我想有选择地将 20 个提交从 A 复制到 B。有什么有效的方法可以做到这一点吗?
我知道我可以 gitcherry-pick 一次提交一个,但是我可以一次提交 20 个吗?这是假设 20 个提交不在一起,并且它们之间有一些我不想复制的提交。
例子。分支 A 提交
4->5->6->7
分支B
1->2->3->8
我想将 4,5,7 复制到 B。
I've got two branches. Lets call them A & B for now. I want to selectively copy something like 20 commits from A to B. Is there any efficient way to do this?
I know I can git cherry-pick commits one at a time but can I do 20 all at once? This is assuming the 20 commits aren't together and there are commits in between them that I do not want copied over.
Example. Branch A commits
4->5->6->7
Branch B
1->2->3->8
I want to copy 4,5,7 over to B.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我宁愿
rebase --interactive A
到 B,因为择优挑选会引入重复提交,这通常不是一个好主意。请参阅“Gitcherry pick 和数据模型完整性”。
话虽如此,您可以在 gitcherry-pick 命令中指定提交集和多个提交。用空格分隔每个提交,并查看如何在 git修订。
I would rather
rebase --interactive A
onto B, because cherry-picking introduce duplicate commits, which is generally not a good idea.See "Git cherry pick and datamodel integrity".
That being said, you can specify sets of commits and multiple commits in a
git cherry-pick
command. Separate each commits by a space, and look at how specifying said commits in gitrevision.您可以将任意数量的提交传递给
gitcherry-pick
将执行您在示例中描述的操作。
You can pass as many commits as you want to
git cherry-pick
Will do what you describe in your example.