user1164061
user1164061

Reputation: 4352

SVN copy only certain directories and subdirectories to a branch

I have the following directory structure in trunk:

trunk
      - dir1
      - dir2
          -subdir1
          -subdir2

I want to copy dir2/subdir2 to my https://mynewbranchurl

If I do svn cp ./dir2/subdir2 https://mynewbranchurl I see subdir2 directly under mynewbranch. What should I do to get dir2/subdir2/contents in mynewbranch?

I do not want to manually create dir2 in mynewbranch.

Upvotes: 1

Views: 3212

Answers (2)

Peter Parker
Peter Parker

Reputation: 29735

You should use the --parents option for the copy command:

svn cp --parents ./dir2/subdir2 http://repourl/branches/my_new_branch/dir2/subdir2

In this way Subversion creates all intermediate directories (I am not sure if you need subdir2, please test it)

Upvotes: 2

Darryl
Darryl

Reputation: 6247

So let's say that http://mysvn.com/repos/branches already exists, and after the copy you want trunk/dir2/subdir2 to be located at http://mysvn.com/repos/branches/my_new_branch, such that trunk/dir2/subdir2/file.txt is located at http://mysvn.com/repos/branches/my_new_branch/file.txt. Just do this:

svn cp ./dir2/subdir2 http://mysvn.com/repos/branches/my_new_branch

Make sure that my_new_branch does not exist before the copy operation. If it does exist, it will place dir2 inside of the existing folder. I think that might be what's giving you grief.

Upvotes: 1

Related Questions