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
因为第一个 shat 不包括在内。这里,“<from-sha>^
”表示 "<from-sha>"
的第一个父级;
我有 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
因为第一个 shat 不包括在内。这里,“<from-sha>^
”表示 "<from-sha>"
的第一个父级;