svn : how to create a branch from certain revision of trunk

SvnBranch

Svn Problem Overview


The following action will only create a branch from the head revision of the trunk. How do I create a branch from a specific revision? Thanks.

$ svn copy http://svn.example.com/repos/calc/trunk \
       http://svn.example.com/repos/calc/branches/my-calc-branch \
  -m "Creating a private branch of /calc/trunk."

Svn Solutions


Solution 1 - Svn

Check out the help command:

svn help copy

  -r [--revision] arg      : ARG (some commands also take ARG1:ARG2 range)
                             A revision argument can be one of:
                                NUMBER       revision number
                                '{' DATE '}' revision at start of the date
                                'HEAD'       latest in repository
                                'BASE'       base rev of item's working copy
                                'COMMITTED'  last commit at or before BASE
                                'PREV'       revision just before COMMITTED

To actually specify this on the command line using your example:

svn copy -r123 http://svn.example.com/repos/calc/trunk \
    http://svn.example.com/repos/calc/branches/my-calc-branch

Where 123 would be the revision number in trunk you want to copy. As others have noted, you can also use the @ syntax. I prefer the clearer separation of the revision # from the URL, personally.

As noted in the help, you can replace a revision # with certain words as well:

svn copy -rPREV http://svn.example.com/repos/calc/trunk \
    http://svn.example.com/repos/calc/branches/my-calc-branch

Would copy the "revision just before COMMITTED".

Solution 2 - Svn

$ svn copy http://svn.example.com/repos/calc/trunk@192 \
   http://svn.example.com/repos/calc/branches/my-calc-branch \
   -m "Creating a private branch of /calc/trunk."

Where 192 is the revision you specify

You can find this information from the SVN Book, specifically here on the page about svn copy

Solution 3 - Svn

append the revision using an "@" character:

svn copy http://src@REV http://dev

Or, use the -r [--revision] command line argument.

Solution 4 - Svn

Try below one:

svn copy http://svn.example.com/repos/calc/trunk@rev-no 
       http://svn.example.com/repos/calc/branches/my-calc-branch 
  -m "Creating a private branch of /calc/trunk."  --parents

No slash "" between the svn URLs.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionpierrotlefouView Question on Stackoverflow
Solution 1 - SvntypeoneerrorView Answer on Stackoverflow
Solution 2 - SvnDan McGrathView Answer on Stackoverflow
Solution 3 - SvnEdward Q. BridgesView Answer on Stackoverflow
Solution 4 - SvnShivaKumarView Answer on Stackoverflow