Reputation: 24134
I have the following git repo:
oooooooooooooo
o o
o V1 o V2
o
o MyChange
I have a git diff
for V1..MyChange
. Now I would like to merge everything up to V2
and create a new diff for V2..MyChange
.
How can I tell Git to auto resolve all conflicts by taking V2
except for the files present in V1..MyChange
diff?
I have tried
git checkout MyChange
git merge V2
and I'm getting 100s of conflicts with both file modifications and file deletions. I just want to take everything from V2
except for the files I'm interested in MyChange
.
Upvotes: 2
Views: 94
Reputation: 10227
It looks like you have a couple patches that are currently applied on top of V1
, and you want to update your repo and apply your patches on top of V2
. As mentioned in @Yehezkel's comment, rebase
is a better way to do this.
Specifically, you can do:
git checkout MyChange
git rebase --onto V2 V1
Or simply:
git rebase --onto V2 V1 MyChange
This will cause your history to look like this:
oooooooooooooo
o o
o V1 o V2
o
o MyChange
You may still have conflicts, but it should be limited to actual conflicts, i.e. files that have changed both in V2
and in your patches.
Upvotes: 1