Creating SVN Branch on Local Repository

svnversion control

I am trying to create an svn branch on a local repository on my computer. Based on my understanding of what I read in the svn book, I am supposed to first create the branch directory (using svn mkdir), then copy from my repository into my working copy's branch directory (is this correct?).

Here are the locations for my repository and working directory:

My local repository: "SVN/repo".
My working copy: "SVN_WORK_COPY/repo/trunk"
My branch destination: "SVN_WORK_COPY/repo/branches/my_code_branch"

When I typed:

    svn copy SVN/repo SVN_WORK_COPY/repo/branches/my_code_branch -m "Created first branch"

I got the following message:

svn: Local, non-commit operations do not take a log message or
revision properties

When I typed:

svn copy SVN/repo SVN_WORK_COPY/repo/branches/my_code_branch 

I got the following message:

svn: 'SVN\repo' is not a working copy

When I typed:

svn copy SVN_WORK_COPY/repo/trunk SVN_WORK_COPY/repo/branches/my_code_branch -m "First Branch"

I got this message again:

svn: Local, non-commit operations do not take a log message or
revision properties

Finally, When I typed:

svn copy SVN_WORK_COPY/repo/trunk SVN_WORK_COPY/repo/branches/my_code_branch

I got:

A SVN_WORK_COPY/repo/branches/my_code_branch\trunk

and my file (code.txt) is inside this trunk directory. However, I doubt very much that I created a branch correctly because

  1. I was not allowed to create a message (using -m)
  2. I did not want the "trunk" directory in "my_code_branch" directory
  3. I did not see the message "Committed revision 4" (Im at revision 4
    currently)

So where did I go wrong?

Best Answer

No, that's not how you create a branch. You first make a copy of the trunk in the SVN repo (the branch is this copy):

svn copy http://the.url/theProject/trunk http://the.url/theProject/branches/my_new_branch -m "created new branch"

Then either you switch your current working copy to this new branch (but you should rename the directory to something other than trunk, because it's confusing) or, if you want to have the trunk and the branch locally, you checkout the branch to another location.