除了1次提交外,我们有一个公关,除了特定提交之外,还可以合并一切吗?
答案 0 :(得分:1)
如果要跳过的提交是分支中的最后一次提交,则可以合并其父级。
branch ... A --- B --- C
/ \
master ... O ... git merge branch^
如果不是,你可以git cherry-pick
除了坏的之外每次提交。此快捷方式是使用git rebase -i
并删除您不想要的行。
branch ... A --- B --- C
/
master ... O ...
$ git rebase -i master branch
(inside editor)
pick 0123456789 A (delete this line)
pick 3456789abc B
pick 6789abcdef C
(save and exit)
branch ... B' --- C'
/
master ... O ...
您还可以合并然后还原提交。
$ git merge branch
$ git revert A
branch ... A --- B --- C
/ \
master ... O ... merge --- ∀
或者在分支中恢复然后合并。
$ git checkout branch
$ git revert A
$ git checkout master
$ git merge branch
branch ... A --- B --- C --- ∀
/ \
master ... O ... merge
答案 1 :(得分:0)
您可以在工作树中合并分支,并在提交之前还原不需要的提交。
git merge --no-commit
branch
git revert --no-commit
unwanted_commit
git commit -m "Merged
branch
(except
unwanted_commit
)"