“Naive” svn merge from branch into trunk?

*爱你&永不变心* 提交于 2019-12-03 23:54:12

Here's how to do it just using SVN (no mucking about in the filesystem):

  1. Check out the trunk revision from which you created the branch (not the HEAD revision).
  2. Commit it to the repository (this undoes all subsequent trunk changes).
  3. Do your reintegrate-merge (your trunk working copy should now be identical to the branch.)
  4. Commit the merged trunk, and you're done!
  1. update to the latest on a branch
  2. copy all files somewhere on your workstation
  3. switch branch to trunk
  4. overwrite using regular windows explorer (only changed files will be overwritten)
  5. commit
Valentin Rocher

A little amelioration to webwesen's answer, since I don't really see a simple way :

  • do a svn export of the branch in some dir
  • copy all files from this dir to the trunk dir
  • commit

To the best of my knowledge, this is currently impossible in svn, so TortoiseSVN can't help you.

To simplify a little bit (okay, a lot), take the svn update command as an example. If there are modifications in your working copy as well as the repository, but no actual conflicts, svn update will simply merge the repository's changes into your working copy.

I don't think there's a way around this. If you had actual conflicts, you could use the --accept ACTION command-line option to keep only the local changes (for example). But if you want to specify an acceptance action for any file changed in both the repository and working copy, you're unfortunately Out Of Luck.

It occurs to me that asking svn developers for a command-line option for this case might be an idea, not that it would be released in time to help you here.

The conflict-resolution issue I mentioned suggests a hideously ugly hack, which I do not recommend. Using your favorite tools, get a list of the files that changed in the branch. Now, for each file in that list, modify it on the trunk by prepending an unusual character to each line. Commit the changes to the trunk. Merge to bring the branch up to date before reintegrating, but use --accept to prevent any of the horrible trunk files from making it in. Then, reintegrate, again using --accept to overwrite the horrible trunk files.

I should add that you can't do this with TortoiseSVN, at least not obviously, because it doesn't support --accept, at least not that I could find.

Well, I said it was hideously ugly. Don't try this at home! (I certainly haven't.)

The "svn merge" command is designed for this purpose, and will allow you to merge in one step. Instructions here.

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