假设我们有分支(从最旧到最新)第一,第二,OG,第四,第五
这些都是分支出来的,然后以不同的顺序合并回工作分支。
在最近的某个时候,上述提交中从最新(第五)到最旧(第一)的范围是 git revert 的目标。
这样做,我的合并(OG)也被恢复了。
我怎样才能把那个提交放回去而把其他的留在外面?
您可以重写构成您想要再次应用的
OG
的提交。这样 git 就不会认为这些修订曾经被合并过……然后你可以将它合并到分支中。假设它是一个接一个的 2 次提交,最终以 OG
结束,你想再次合并:
git checkout -b temp OG~2
# let's rewrite the 2 commits
git cherry-pick HEAD..OG # this will create 2 new commits just like the original 2... but they are not the same commits
# now you can merge this branch
git checkout fifth
git merge -m "Merging OG again" temp
那应该有用