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

pierrotlefou picture pierrotlefou · Feb 25, 2010 · Viewed 134.6k times · Source

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."

Answer

typeoneerror picture typeoneerror · Feb 25, 2010

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".