How could I use a different strategy for just one commit in a rebase?

﹥>﹥吖頭↗ 提交于 2019-12-23 03:13:59

问题


Given this:

master  A---B---G---H---I
             \
branch        C---D---E---F

Is there anyway to get to the following, but using -X theirs only for the C commit?

master  A---B---G---H---I
                         \
branch                    C'--D'--E'--F'

(I've created a branch for migrating a big solution from VS2008 to VS2010. The first commit on the branch was the one that changed all the project files. Now I would like to update the branch to get the latest changes, but without having to manually merge any conflicts arising from tool-generated code)


回答1:


You could try to:

  • merge first C to master, using one the the merge --strategy=theirs detailed in this SO answer.
  • then git rebase master (which shouldn't repeat commit C, since it has already been merged and is identical to the C of branch).



回答2:


This obvious rebasing step, pulled straight from the manuals doesn't work?

git checkout branch
git rebase master



回答3:


guess, you can use cherry-pick to apply one commit anywhere you want:

git checkout master
git cherry-pick -x C

this will apply C patch to master. then you can rebase your branch on master, because it will contain C inside

git checkout master
git rebase master


来源:https://stackoverflow.com/questions/7632678/how-could-i-use-a-different-strategy-for-just-one-commit-in-a-rebase

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!