Ignore the files from merging

2019-07-30 23:36发布

问题:

I was trying to merge from my branch to trunk.Merge type was Range of revision. Kept the text blank so that I need to get all the revisions merged. Once done all the pom.xmls got conflicted. It is difficult to edit all the poms resolve the conflicts.

I would like to know is there any option to ignore the files which I do not need to merge with.

Version of tortoise svn is 1.6

回答1:

When you do a merge, you can accept which conflict you prefer to take. In Subversion, you can select theirs meaning the branch you're merging from or yours meaning the branch you're working on. In the command line, you can also specify if you want to only accept theirs or yours for just where the conflicts are, or the whole file. TortoiseSVN also offers the same options.

Of course, if pom.xml is truly messed up (maybe one of the developers decided to restructure the whole thing, so there's little match between the trunk and your branch), you can always do a revert after the merge. It's like skipping pom.xml during the merge.

I've had problems of developers helpfully restructuring a file and then having problems with merging because merges are mostly textual analysis, and can't handle file restructuring. The best thing to do is to revert pom.xml, and then find some sort of XML diff tool that can help you figure out the differences, and merge the ones you do want to keep.

Then make the changes that are needed in the pom.xml, and commit the merge after doing a manual merge of the pom.xml file.



回答2:

AFAIK, you can't ignore files being merge, but after the merge completed (and conflicted were created), you're able to resolve conflicts in specific files using "your side" version or "their side" version of the file. To cite svn help resolve manual:

--accept ARG             : specify automatic conflict resolution source
                         ('base', 'working', 'mine-conflict',
                          'theirs-conflict', 'mine-full', 'theirs-full')

No idea how that maps onto TortoiseSVN though…


Update: disregard my answer: this explains that the svn merge command has the --accept command-line option as well, and it's possible to choose whether to use "ours" or "theirs" version of files when merging.