You are here

How to create SVN branch from trunk

Submitted by Asif Nowaj, Last Modified on 2019-11-08

SVN Trunk code should always be the production copy of the codebase. At least this is how I see it.

When a new project work starts an existing application or required a significant amount of code change then you might need to create a separate branch from working production copy of the code. Apart from that, there could be many other reasons to create separate SVN branch from trunk like multiple team, parallel work etc.

So we need to create a new SVN branch from trunk version of the codebase and then work on it. Presumably, you have tortoiseSVN client installed in your machine to communicate with SVN server. Hence, I'll guide in terms of tortoise SVN version 1.9.4.

Steps:

  1. Create folder which will be your working copy of the code. Let's say "MyProjectCodeWorkingCopy".

  2. Right click on the folder called "MyProjectCodeWorkingCopy" and select "SVN Checkout".

  3. Provide "URL of repository" as your repository trunk location. Make sure "Checkout directory" is selected as your "MyProjectCodeWorkingCopy" location. Checkout Depth as "Fully recursive" and Revision as "Head revision". Then press "OK".

  4. This will download all the codes in your location directory. Wait till it is complete.

  5. Now right click on "MyProjectCodeWorkingCopy" and select "TortoiseSVN"=>"Branch/tag"

  6. Make sure "From WC / URL" is showing as your trunk code location. Provide "To path" as "/branches/<your code branch name>", as you type in, you can check the SVN path of your branch just below it as "Destination URL".

  7. Provide a suitable log message like "Initial copy of the branch for blah blah work".

  8. Select "HEAD revision in the repository" in "Create copy in the repository from" section. [Here actually you create a new branch from a particular trunk revision].

  9. Tick "Switch working copy to new branch/tag". [This will make your working code directory connected with the newly created branch] Then select "OK".

It's done. A branch is created in the SVN repository under "branches" directory with name "<your code branch name>" [step 6] and your local codebase is connected to it.

Discussion or Comment

If you have anything in mind to share, please bring it in the discussion forum here.

https://forum.everyething.com/svn-f34/