SVN: Copy modified/added files from trunk to branch

svn

I'm a bit lost with Subversion (1.5+) here:

I modified the trunk in my local working copy, added new files and directories, etc., but eventually I decided that it would be better to work on a separate branch, so I created one from the base revision of my trunk.

That was the easy part. But what's the best way to move my locally modified files, including added files and directories, to the branch now?

I already tried to switch the trunk like so:

project/trunk $ svn switch svn+ssh://lisa@example.com/project/branches/mybranch

This worked for some files but then gave me an error message like that when it occurred an added directory:

svn: URL 'svn+ssh://lisa@example.com/svn/project/branches/mybranch/component/impl/src/main/java/com/xxx/yyy/addeddirectory' doesn't match existing URL 'svn+ssh://lisa@xxx.com/project/branches/mybranch/addeddirectory' in 'component/impl/src/main/java/com/xxx/yyy/addeddirectory'

Thanks for any pointers!

Best Answer

If you haven't committed changes then you could create a patch file from your local copy of files:

svn diff > patch.txt

and then apply that to a new branch

patch -p0 -i patch.txt

More of an explanation here:

http://ariejan.net/2007/07/03/how-to-create-and-apply-a-patch-with-subversion/

If you're using Windows you can do this with TortoiseSVN also...