[英]Git/source tree move specific commits at branch B to branch A
首先,转到branchA
并在此处选择要cherry-pick
的两个提交。
$ git checkout branchA
$ git cherry-pick <commit1> # commit1 = 0a18e0f
$ git cherry-pick <commit2> # commit2 = e604ce4
$ git push origin HEAD # push to remote
现在通过revert
或rebase
从branchB
删除两个提交。 Revert 更可取,因为它不会更改 git 历史记录。
恢复:
$ git checkout branchB
$ git revert <commit1>
$ git revert <commit2>
$ git push origin HEAD
变基:
$ git checkout branchB
$ git rebase -i efb2443 # go back to the commit before the two commmits you want to remove
Now comment out (adding `#` before the commit hash) the two commits you want to remove.
$ git push -f origin HEAD # you need to force(-f) push as history is changed here by rebasing
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.