Assume I have this one conflict in 200 files:
<<<<<<< HEAD
/* Version 1.0.0 */
/* Date 2017-05-30 */
=======
/* Version 1.0.1 */
/* Date 2018-11-30 */
>>>>>>> release/1.0.1
I know for sure that I want the 1.0.1
version in all files. But simply using --theirs
for all files is not feasible since I have other modifications too that shall be kept from --ours
.
Is there a way to just resolve this one conflict with --theirs
and then manually resolve other conflicts (in just a handfull of files) manually?
To fix this situation, you need to create new commits that mimic those on the branch. The easiest way to do that is with git rebase -f . Now you can merge branch in again.
Often, merge conflicts happen when people make different changes to the same line of the same file, or when one person edits a file and another person deletes the same file. You must resolve all merge conflicts before you can merge a pull request on GitHub.
The only way I can think to make git do what you're asking during conflict resolution, would be to write a custom merge driver that detects and "fixes" the version info before invoking the normal merge-file
process. That's doable, but takes a bit of setup (see the git attributes
docs under the merge
attribute, where it talks about custom merge drivers).
If you can tolerate the extra step, it might be easier to just write a script (something like perl or even awk would be well-suited to the task) that finds and fixes that specific conflict block, and run that script over the conflicted merge output before going on to manually resolve the remaining changes. The biggest down-side to this - and the reason I might consider the merge driver approach - is that if a file conflicts only due to the version block, you'll have no manual work but the file will still be in a conflicted state - so you'll have to check each file to see if there is remaining conflict resolution to be done.
It seems to me it might be wroth revisiting the aspect(s) of your workflow that lead you to expect these conflicts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With