问题
I have a branch in SVN that I want to update with new changes from the trunk. I also have some files with local changes in this branch. I do not want to commit some of these changes just yet.
If I try to merge the changes from trunk into this branch, it gives me an error:
Error: Cannot merge into a working copy that has local modifications
Is there a way to merge the trunk into the branch remotely on the server, so I can just update the branch normally afterwards?
回答1:
It is highly recommended that you use a clean and up to date copy of the working directory for merging.
However, if you want to break these cardinal rules and shoot yourself in the foot, Subversion gives you the means and the bullets:
$ svn merge --force --allow-mixed-revisions $repo_url
The --allow-mixed-revisions
parameter will allow a merge to take place even if there are mixed revisions in the working copy. The --force
parameter will allow you to merge even if there are local changes.
There's actually a few scenarios where using --force
might be a good idea, but I can't think of any reason at all for --allow-mixed-revisions
.
回答2:
No. You must go through the merge process on a working copy, resolve the potential conflicts, and commit.
But the working copy could be a different working copy from the one you're currently working on: just do a fresh checkout of the branch to a new directory, make the merge in this new directory and commit.
来源:https://stackoverflow.com/questions/17536528/merging-trunk-into-a-branch-that-has-local-changes