繁体   English   中英

git将两个分支从一次提交合并到HEAD

[英]git merge two branch from one commit up to HEAD

我有2个分支-> A和B

A比B领先20。

我想将A的最后3个提交合并到B中,并且我知道例如执行命令git merge d8329f ,它将合并所有提交直到给定的SHA提交(不结束)。

git中有什么东西像git merge d8329f fdf4fc3来合并这两个提交之间的提交(包括两个给定的提交)?

您可以使用git cherry-pick <commit>

$ git checkout A
# copy the last 3 commit sha somewhere else 

$ git checkout B 
$ git cherry-pick <commit1> <commit2> <commit2>

# cherry pick a range of commits
$ git cherry-pick <from-sha>^..<to-sha>

注意: from-sha处的^ ,因为不包括first sht。 在这里,“ <from-sha>^ ”表示“ <from-sha>^ ”的第一父"<from-sha>"

更多摘樱桃的例子

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM